Iam pretty new to Objective c,Iam unable to add NSmutable array contents to NSarray here.
- (void)viewDidLoad {
markarry=[[NSMutableArray alloc]init];
HolidayAppDelegate *delegatObj = (HolidayAppDelegate *)[UIApplication sharedApplication].delegate;
for (int i=0;i<[delegatObj.Datearray count]; i++) {
NSString *Str=[delegatObj.Datearray objectAtIndex:i];
NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM-dd-yyyy"];
[dateFormatter setTimeZone:gmt];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[dateFormatter setLocale:usLocale];
NSDate *dateFromString;
dateFromString = [dateFormatter dateFromString:Str];
[markarry addObject:dateFromString];
[dateFromString release];
[Str release];
}
}
I need to add markarry contents to the nsarray.
Thanks
Very Simple
UPDATE
Ok it seems your string is nil when you create it using dateformatter. Try to debug your app you will find the solution.[dateFormatter setDateFormat:@”MMMM-dd-yyyy”]; the format you are using here mmust be same as the string as. Otherwise you will get nil in your dateFromString object.