One Quickie


Beware BOOL results from objc_msgSend (Objective-C->Random)
Courtesy of David Philip Oster, from GTMNSEnumerator+Filter.m:
// We must take care here, since Intel leaves junk in high bytes of return register
// for predicates that return BOOL.
// For details see: 
// unibin chapter and verse (link currently broken courtesy of Apple)
// and
//comment at red-sweater.
- (BOOL)filterObject:(id)obj returning:(id *)resultp {
  *resultp = obj;
  return ((BOOL (*)(id, SEL, id))objc_msgSend)(obj, operation_, object_);
}
The explicit cast to the expected return value gets rid of the junk.



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com