Skip to content

Instantly share code, notes, and snippets.

@iwill
Created June 8, 2013 16:19
Show Gist options
  • Select an option

  • Save iwill/5735703 to your computer and use it in GitHub Desktop.

Select an option

Save iwill/5735703 to your computer and use it in GitHub Desktop.
Objective-C Macros
#define OR ? :
#define NSStringFromValue(value) [@(value) description]
@iwill
Copy link
Copy Markdown
Author

iwill commented Jun 8, 2013

// OR
STAssertEquals(YES OR NO, YES, @"YES OR NO");
STAssertEquals(NO OR YES, YES, @"NO OR YES");
STAssertEquals(123 OR 0, 123, @"123 OR 0");
STAssertEquals(0 OR 123, 123, @"0 OR 123");
STAssertEqualObjects(@"string" OR nil, @"string", @"string OR nil");
STAssertEqualObjects(nil OR @"string", @"string", @"nil OR string");

// NSStringFromValue
STAssertEqualObjects(NSStringFromValue(123), @"123", @"123");
STAssertEqualObjects(NSStringFromValue(1.23), @"1.23", @"1.23");
STAssertEqualObjects(NSStringFromValue(12.3f), @"12.3", @"12.3f");
STAssertEqualObjects(NSStringFromValue(YES), @"1", @"YES");
STAssertEqualObjects(NSStringFromValue("string"), @"string", @"string");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment