Skip to content

Instantly share code, notes, and snippets.

@dataxpress
Created August 26, 2014 04:46
Show Gist options
  • Select an option

  • Save dataxpress/479c72bee9a837d039f0 to your computer and use it in GitHub Desktop.

Select an option

Save dataxpress/479c72bee9a837d039f0 to your computer and use it in GitHub Desktop.

Revisions

  1. dataxpress created this gist Aug 26, 2014.
    60 changes: 60 additions & 0 deletions test.m
    Original 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
    }


    }
    }