Created
August 26, 2014 04:46
-
-
Save dataxpress/479c72bee9a837d039f0 to your computer and use it in GitHub Desktop.
Revisions
-
dataxpress created this gist
Aug 26, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ #import <Foundation/Foundation.h> @interface SomeClass : NSObject -(BOOL)arrayHasStuff; -(BOOL)otherArrayHasStuff; @property (nonatomic, retain) NSArray *array; @property (nonatomic, retain) NSArray *otherArray; @end @implementation SomeClass -(id)init{ if(self = [super init]) { _array = @[@"a",@"b",@"c"]; _otherArray = @[@"d",@"e",@"f",@"g"]; } return self; } -(BOOL)arrayHasStuff { return self.array.count; } -(BOOL)otherArrayHasStuff { return self.otherArray.count; } @end int main(int argc, char *argv[]) { @autoreleasepool { SomeClass *x = [[SomeClass alloc] init]; if([x arrayHasStuff]) { NSLog(@"Array has stuff"); // prints } if([x otherArrayHasStuff]) { NSLog(@"Other Array has stuff"); // prints } if([x arrayHasStuff] == [x otherArrayHasStuff]) { NSLog(@"Both arrays have the same state of havingness"); // does not print } } }