nsmutablearray

Objects not being added to NSMutableArray Objective -C

跟風遠走 提交于 2020-01-11 03:28:12
问题 I'm trying to simply add objects to a mutable array but they WILL NOT insert. I'm not getting errors or anything and I can't figure out whats going on. In my main delegate file I split an array into 4 separate strings like so. NSArray *split=[currentParsedCharacterData componentsSeparatedByString:@"|"]; NSLog([split objectAtIndex:3]); NSString *date=[split objectAtIndex:0]; NSString *venue=[split objectAtIndex:1]; NSString *event=[split objectAtIndex:2]; NSString *city=[split objectAtIndex:3]

How to remove elements in NSMutableArray or NSMutableDictionary during enumeration?

一曲冷凌霜 提交于 2020-01-10 23:41:30
问题 I am using block based enumeration similar to the following code: [[[rows objectForKey:self.company.coaTypeCode] objectForKey:statementType] enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id coaItem, NSUInteger idx, BOOL *stop) { // block code here }] I would like to remove some of the objects during the enumeration process depending on the their object values. How could I do this? I know that manipulating an mutable array or dictionary (NSMutableArray or NSMutableDictionary

Program crashes when adding NSMutableArray of strings to a UILabel

二次信任 提交于 2020-01-07 08:49:12
问题 When I add this array of strings to the summaryText UILabel it crashes. Please let me know how to fix this. NSMutableArray *arr = [[NSMutableArray alloc]init]; arr = [Singleton getArray]; NSString *str = [arr componentsJoinedByString:@"\n"]; summaryText.text = str; This is what was brought up when i command clicked summaryText @implementation TotalViewController @synthesize tax,taxLabel,total,totalLabel,final,finalLabel,fiveLabel,threeLabel,twoLabel,five,three,two, points, pointsLabel

add a NSArray to NSMutableArray

本小妞迷上赌 提交于 2020-01-07 08:21:25
问题 i want to add a NSArray to my NSMutable ( init in the appdelegate ) this is my code, the method is call each time a button (male, female, couple) is pressed so an NSArray has to be add to the MutableArray but i don't know i tried stuff but doesnt work. : - (void) sexChoosen:(NSString *) sexe { NSError *err; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Boxes" inManagedObjectContext:context]; [request setEntity

Saving an Mutable array of images and loading them

送分小仙女□ 提交于 2020-01-07 04:40:41
问题 I have part of my app that will take a photo and the person can elect to save it i then save the image to an array but what ways can I save it to the phone WITHOUT it being put in the photo library. I tried UIImage *image = imageView1.image; [array addObject: image]; NSUserDefaults *default = [NSUserDefault standardDefaults]; [defaults setObject:image withKey:@"saved image"]; //not exact code just showing the method I use to save the array of images [defaults synchronize]; then i also use

Mutable array comparison for copied objects

此生再无相见时 提交于 2020-01-07 00:04:46
问题 I am trying to do array comparison on 2 mutable arrays. In one of the array, i am storing my model objects and in the other array I am storing a copy of the model objects using [myObject copy] . My model object is a subclass of NSObject so I have added the copyWithZone: method as well. However when I do array compare using isEqualToArray on these two arrays it always returns false. Will the compare not work on copied objects? Or am I going wrong somewhere else? P.S : As an overview, what I'm

How to insert object already existing objects in NSMutableArray list

我的梦境 提交于 2020-01-06 19:57:11
问题 I am getting a problem, while inserting an object into the main List. [editContactList addObject:editcontacts]; [editObject.contactList insertObject:editContactList atIndex:0];//error as mutating method sent to immutable object [editcontacts release]; 回答1: If you get that particular error, you don't actually have an NSMutableArray ; you have an NSArray . Which is immutable. (Note that simply casting an NSArray to NSMutableArray does nothing, the array itself needs to be an instance of a

NSMutableArray not saved NSUserDefault

◇◆丶佛笑我妖孽 提交于 2020-01-06 18:12:02
问题 I'm trying to save a NSMutableArray with NSUSerDefault and then open the array. Here some code: -(IBAction)btnSave{ Class *aClass = [[Class alloc]init]; aClass.idClass=@"aaaxxx"; aClass.nameClass=@"hello"; [myArray addObject:aClass]; NSUserDefaults *arrayDefault=[NSUserDefaults standardUserDefaults]; [arrayDefault setObject:myArray forKey:@"savedArray"]; [arrayDefault synchronize]; } and - (void)viewDidLoad { [super viewDidLoad]; myArray=[[NSMutableArray alloc]init]; NSMutableArray

NSMutableArray not saved NSUserDefault

只谈情不闲聊 提交于 2020-01-06 18:10:08
问题 I'm trying to save a NSMutableArray with NSUSerDefault and then open the array. Here some code: -(IBAction)btnSave{ Class *aClass = [[Class alloc]init]; aClass.idClass=@"aaaxxx"; aClass.nameClass=@"hello"; [myArray addObject:aClass]; NSUserDefaults *arrayDefault=[NSUserDefaults standardUserDefaults]; [arrayDefault setObject:myArray forKey:@"savedArray"]; [arrayDefault synchronize]; } and - (void)viewDidLoad { [super viewDidLoad]; myArray=[[NSMutableArray alloc]init]; NSMutableArray

Memory is not getting released

拟墨画扇 提交于 2020-01-06 18:03:56
问题 When I run the following program ... application is holding some 5MB of memory even after releasing all objects ... when I don't add an object to list everything works fine ... but I am not sure why application is holding memory even after releasing the list. I have read this link "NSMutableArray big memory hog?" and even tried with custom mutable array by mikeash MACollections -- in all the cases ... the memory allocated in the loop never get released if I add the object into list. Please