From 8d29af68e02e7ebf54014dc79ecb47a52e56fc96 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Tue, 21 Feb 2012 18:30:13 +0000 Subject: [Author: thomasvl] 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) --- Foundation/GTMNSObject+KeyValueObserving.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Foundation/GTMNSObject+KeyValueObserving.m') diff --git a/Foundation/GTMNSObject+KeyValueObserving.m b/Foundation/GTMNSObject+KeyValueObserving.m index fa07fab..8d6580d 100644 --- a/Foundation/GTMNSObject+KeyValueObserving.m +++ b/Foundation/GTMNSObject+KeyValueObserving.m @@ -667,13 +667,18 @@ GTM_METHOD_CHECK(NSObject, + (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 -- cgit v1.2.3