I have an array in which I'm adding objects, but the array is remaining empty even after adding the objects. Here are the code:
Event.h
@interface Event : NSObject
@property NSString *name;
@end
Code where objects are added to the array
NSMutableArray *events;
NSArray *event_string = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];
for (NSString *currentEventString in event_string) {
Event *currentEvent = [Event new];
[currentEvent setName:currentEventString];
[events addObject:currentEvent];
}
NSLog(@"Number of events:%d",[events count]);
I'm getting this output:
Number of events:0
eventsarray