Skip to content

Commit

Permalink
[Author: thomasvl]
Browse files Browse the repository at this point in the history
Add check for iOS and Xcode 4 behaviors that makes everything appears to
  be a system path by old check.

R=dmaclach
DELTA=7  (5 added, 0 deleted, 2 changed)

git-svn-id: http://google-toolbox-for-mac.googlecode.com/svn/trunk@511 7dc7ac4e-7543-0410-b95c-c1676fc8e2a3
  • Loading branch information
gtm.daemon committed Feb 21, 2012
1 parent 540f0b7 commit fc2d093
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Foundation/GTMNSObject+KeyValueObserving.m
Expand Up @@ -667,13 +667,18 @@ - (void)_gtmCheckAddObserver:(NSObject *)observer

+ (BOOL)_gtmAccessInstanceVariablesDirectly {
// Apple has lots of "bad" direct instance variable accesses, so we
// only want to check our code, as opposed to library code.
// only want to check our code, as opposed to library code. iOS simulator
// builds copy the app into the user's home directory. Xcode 4 also changes
// the default location of the output directory. Don't count being within
// the user's home and under "/Library/" as being a system library.

// If this turns out to be slow, we may want to consider a cache to speed
// things up.
NSBundle *bundle = [NSBundle bundleForClass:self];
NSString *path = [bundle bundlePath];
return [path rangeOfString:@"/Library/"].location != NSNotFound;
BOOL hasLibrary = [path rangeOfString:@"/Library/"].location != NSNotFound;
BOOL startsWithUser = [path hasPrefix:@"/Users/"];
return !startsWithUser && hasLibrary;
}

#endif // GTM_PERFORM_KVO_CHECKS
Expand Down

0 comments on commit fc2d093

Please sign in to comment.