I'm using a property of NSArray type. Then I'm trying to initialize or setting values for the NSArray. When I use shorthand assignment, I'm getting the output. But when I'm trying with long initialization style, I'm not getting the result. What should be the right way for the latter??
Here is the code snippet:
@property NSArray * moods;
//shorthand assignment
self.moods=@[@"Happy",@"Sad"];
NSLog(@"Hello %@",[self moods]);
This is working. But when I tried:
//long initialization style
[[self moods]initWithObjects:@"Happy",@"Sad", nil];
NSLog(@"Hello %@",[self moods]);
This isn't doing the same way. Suggest me something please.
[[self moods]initWithObjects:@"Happy",@"Sad", nil];