Last active
January 16, 2019 13:08
-
-
Save onurhuseyincantay/17e35536ad99628f4945842bdd3760c0 to your computer and use it in GitHub Desktop.
Basic Objective-C Declarations
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 characters
// NSString | |
NSString *someAllocInitString = [[NSString alloc] initWthString: @“The String”]; | |
NSString *someLiteralDeclaredString = @"The String"; | |
// NSArray | |
NSArray *someAllocInitArray = [NSArray arrayWithObjects:@“firstObject”,@“secondObject”,@“thirdObject”]; | |
NSArray *someLiteralDeclaredArray = @[@“firstObject”,@“secondObject”,@”thirdObject”]; | |
// NSDictionary | |
NSDictionary *someAllocInitDictionary = [NSDictionary dictionaryWithObjectAndKeys : @“firstValue”,@“firstKey” | |
,@“secondValue”,@“secondKey”] | |
// This would be more confusing because it has an order of value key not key value | |
NSDictionary *someLiteralDeclaredDictionary = @{@“firstKey”: @“firstValue”,@“secondKey”:@”secondValue”}; | |
// If we want to get a specific value for an key without literals it would be like; | |
NSString *firstValue = [someDictionary objectForKey:@“firstKey”]; | |
//But with literals it would something like this; | |
NSString *firstValue = someDictionary[@“firstKey”]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment