nsmutablearray

NSNumbers in stored array disappear.

So I stored an NSMutableArray of NSNumber objects into the file "times.plist" then I load it and retain it on launch and the NSLog shows the correct value, but later the [times count] equals 0. Why are the NSNumbers disappearing? times = [[NSMutableArray alloc] initWithObjects:[[NSNumber alloc] initWithFloat:time],nil]; ... [times writ...

What's wrong with and extern NSMutableArray?

Hi Guys! So I've been doing a lot of reading. And I have been able to finally declare an extern MutableArray and access it from different Views. I have two views: 1) Testing View Controller 2) Test2 I declare the array as follows: TestingViewController.h extern NSMutableArray *myArray; #import <UIKit/UIKit.h> @interface TestingVie...

NSMutableArray Leaks in Loop

Hi, I´m using instruments to find memory leaks, and it found a lots! But i don´t know how to fix it. @property(nonatomic, retain) NSMutableArray *wycategories; ... ... self.wycategories = [[NSMutableArray alloc]init]; ... ... for (CXMLElement *node in nodes) { //Instruments say that here there are a lots of memory leaks Wa...

Singleton NSMutableArray accessed by NSArrayController in multiple NIB's

Early warning - code sample a little long... I have a singleton NSMutableArray that can be accessed from anywhere within my application. I want to be able to reference the NSMutableArray from multiple NIB files but bind to UI elements via NSArrayController objects. Initial creation is not a problem. I can reference the singleton NSMutab...

How to solve the leaks in the following code? ObjectiveC

Hi guys, I getting leak here which is written in the appDelegate.m -(NSMutableArray*)getSalutationList { NSMutableArray *list=[[NSMutableArray alloc]init]; [list addObject:@"Dr."]; [list addObject:@"Mr."]; [list addObject:@"Mrs."]; [list addObject:@"Miss."]; [list addObject:@"Ms."]; return list; //return [...

Return mutable or copy

If you have a method in objective c that builds an array or dictionary using a mutable object, should you then copy the object, or return the mutable version? This is probably a case of opinion but I have never been able to make up my mind. Here are two examples to show what I am talking about: - (NSArray *)myMeth { NSMutableArray *...

Accessing properties of object in an nsmutablearray iphone sdk

Hi all, In my aplication, I have an nsmutablearray which stores a number of types of objects. All these objects are having two similar properties: id, type. What I'm doing is I'm fetching the current working object in a 1-element array and accessing its properties id, type from within another class. This class is not aware which type o...

Mutable array is automatically changed to immutable, while adding the object to it. why?

Hi Guys, These are setter and getters. -(NSMutableArray*)contactList { return contactList; } -(void)setContactList:(NSMutableArray*) aContactList { [contactList release]; contactList=aContactList; //its working fine but leaks // contactList=[aContactList copy]; // If I keep like this getting exception as mutatin...

How to add an object to the end of an NSMutableArray

I have the following code NSMutableArray *plistArray = [[NSMutableArray alloc] initWithContentsOfFile:filepath]; [plistArray insertObject:title atIndex:2]; but would like to rather add the object to the end of the array. How can this be done, and do I need to set the last value to nil, at the moment I dont and it works fine. Regard...

Need clarification on addObjectsFromArray function

I have the following code (both items and itemsCopy are NSMutableArray's): //DO: populate items w/ 30 elements [self.itemsCopy addObjectsFromArray:self.items]; //DO: remove all elements in items Results Begin Pass 1: itemsCopy = 0 items = 30 End Pass 1: itemsCopy = 30 items = 0 Begin Pass 2: itemsCopy = 0 items = 30 End Pass 2: it...

NSMutableArray = null in new view error

Hi, I'm trying to work out how to move data, parsed from an RSS feed into a UITableView into an entirely new view, for example a UIMapKit, but not having much luck. Each time I get "dog.name" (see below) = null. I have an NSMutableArray, called "Dogs". It's created in a "currentDogstableview" class - which downloads the data from an RS...

Is removeAllObjects and release of an NSMutableArray are both have same functionality?

Hi Guys, I have one doubt NSMutableArray *array=[[NSMutableArray alloc]init]; here some memory is allocated then how can we release this memory, whether using removeAllObjects method or [array release]; Are both have same functionality? Thank You, Madan Mohan. ...

Using an NSMutableArray instead of an NSFetchedResultsController

I've recently come to learn that NSFetchedResultsController is an extremely buggy class and its been causing me headaches for a while now with my rather large Core Data app. Would it be appropriate to use an NSMutableArray to feed the table view instead of an NSFetchedResultsController? What I'm talking about is, temporarily creating a ...

How do I save objects in NSMutableArray after application is terminated?

Hi, I would like to save objects that the user adds to a NSMutableArray that I will be able to see and use even if I quit the application. I tried to use NSUserDefaults but I'm doing something wrong. Thanks! ...

UITableView and numberOfRowsInSection crash

Hi, I have a problem when trying to delete rows from my UITableView: The UITableView gets the number of rows from NSMutableArray: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [alertsArray count]; } I add objects to the NSMutableArray in this way: - (void)saveButton:(id)sender { [...

Serialize an Array of data

I currently write to and read from an array of data, and use the index of each element to achieve something. I need a way to store this array, I looked at the user defaults, but that stores a dictionary, with retieval using keys. I will not know what key was stored. What is the best was to store ths array of data on the iphone? Regards...

Objective C - Lvalue required as left operand of assignment

Hi, I get the error (Lvalue required as left operand of assignment) for this code: [[addAlertViewController alertsArray] = [NSMutableArray arrayWithObjects:nil] retain]; How can I fix it? ...

How can I store SpaceManager cpShape's in something like an array?

I'm trying to create a squishy ball with Cocos2d and Chipmunk (via SpaceManager) using a bunch of rects all chained together then joined with springs to a central body. Something like these examples But in order to do this, i think I need to store all the cpShapes in an array after I've created them so I can then loop through the arra...

How to tell how may unique elements there are an NSArray

I've got an array (actually a mutable array) of NSStrings, and I want to find out how many unique elements the are in the array. For instance, say the array is made up of: Orange, Lemon, Lemon, Orange, Lemon Then there are just two unique elements (Orange and Lemon). And this array: Paul, Steve, John, Harry, Paul, John ..has four ...

Retrieving data from a NSDictionary

I am not quite sure I understand how to do the following. If I wanted to add e.g. an author and a title (key, value) to a dictionary. Fill that dictionary with data, then have another dictionary for say e.g. k = genre v = artist name and fill it with data. Then I want to add the dictionaries to an array. Firstly how is that done? a...