How to add NSmutable Array Values to NSarray
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 dateFromSt开发者_开发技巧ring:Str];
[markarry addObject:dateFromString];
[dateFromString release];
[Str release];
}
}
I need to add markarry contents to the nsarray. Thanks
Very Simple
NSArray *newArray = [NSArray arrayWithArray:markarry];
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.
精彩评论