nsmutablearray

NSMutableArray vs. NSDictionary for a table view

I have a table view that is populated by objects in an array. I want to give the user the option to delete table entries. I was wondering if it would be easier if I used NSDictionary instead of NSMutableArray? How do you know when to use NSDictionary instead of NSMutableArray? ...

NSMutableArray arrayWithArray: vs. initWithArray:

These both work in my app without any noticeable difference: 1) theArray = [[NSMutableArray alloc] initWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:theData]]; 2) theArray = [NSMutableArray arrayWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:theData]]; [theArray retain]; However, are they really equivalent? (1) has an...

How does the objective-c SBJson library map an array? (do you reccomend it?)

SBJsonParser *parser = [[SBJsonParser alloc] init]; NSMutableArray *componenti = [parser objectWithString:@"[\"Item1\",\"Item2\"]"]; NSAssert([componenti isMemberOfClass:[NSMutableArray class]],@"err"); This code gives me an assertion failed. What is wrong? The header file says: @brief The JSON parser c...

Can't access an NSMutableArray created with Json in another object.

I create an NSMutableArray: SBJsonParser *parser = [[SBJsonParser alloc] init]; NSMutableArray *components = [parser objectWithString:@"[\"Item1\",\"Item2\"]"]; then I access it from the same method: no problem! Then I try to access it from another object: crash!!?? It doesn't happen if i create the NSMutableArray with other means (e....

multiple objects for a single index in an NSArray

Is it possible to store multiple objects for a single index in an NSArray? ...

How to reference a function from one .m file in another?

Hi, this is a bit of a newbie question but I can't seem to find it anywhere. I have defined a class in a set of .h/.m files and have a separate .h/.m for drawing. What I'm trying to do is create an array of objects from this class, and draw them sequentially to the screen. Of course, I'm getting a 'squares' undeclared (first use in this...

Accessing a UITextField from an array in Objective-C

I have 4 UITextFields that I'm dynamically creating, in the viewDidLoad, which works good. I want to reference those objects when the UISlider value changes. Right now I'm storing those objects in a NSMutableArray and accessing them like so from the sliderChanged method: NSInteger labelIndex = [newText intValue]; labelIndex--; NS...

Size of the NSMutable Array in objective C?

Hi, everyone, I want to ask the size of the NSMutable Array can be 2000? If not, is it possible to open an array to store 2000 elements. The elements is the user-defined object. Thank you. ...

NSMutbleArray - add/remove objects with properties - leaks

Hi guys, i have a leak issue in my app. I'm trying to add and remove objects to a NSMutableArray. Here is the class Demande : @interface Demande : NSObject { //attibuts de la classe demande NSString *demId; NSString *demStatut; NSString *demTitle; NSString *demCreated; NSString *demIdCopro; NSString *demIdImmeuble; NSString *demIdLo...

Using NSMutableArray in a class

Whenever I try to add something to my array in the method nothing gets added to the array. I'm wanting it to when you press the button it will add a new object to the array. // JBNumberGeneration.h #import <Cocoa/Cocoa.h> @interface JBNumberGeneration : NSObject { IBOutlet NSTextField *displayLabel; int randNum; int level; int i...

ObC: How to convert a memory pointer to dataP

Hi, I have a custom data container object of type RowOfPlayerData. When I try to display a RowOfPlayerData object in NSLog, the system doesn't know how to display it, so it just shows the address of the object. I am trying to figure out how i can display, in an NSLog statement, what is at that address so i can use the data. I am trying...

How to change this so that it returns arrays

The following code works perfectly and shows the correct output: - (void)viewDidLoad { [super viewDidLoad]; [self expand_combinations:@"abcd" arg2:@"" arg3:3]; } -(void) expand_combinations: (NSString *) remaining_string arg2:(NSString *)s arg3:(int) remain_depth { if(remain_depth==0) { printf("%s\n",[s UTF8Stri...

Objective C dynamic array creation

I have an entity which stores generic information about an event. In the entity, the date the event took place is stored. My view hierarchy is such that I want the user to be able to select a year, which loads another view requesting the month in the selected year. This finally opens a view with a record of all the events that took plac...

How to check if an object exists in an NSMutableArray

Is there a method, like containsObject: for NSMUtableArrays to check if an object exists in there without having to loop through the whole array and check each element? What's the best way to check if an object exists in an NSMutableArray? ...

mutableCopy memory leak

Can anyone shed some light as to why this use of mutableCopy is leaking memory? - (id)objectInListAtIndex:(unsigned)theIndex { NSSortDescriptor *descriptor = [[[NSSortDescriptor alloc] initWithKey:@"noteNumber" ascending:YES] autorelease]; [list sortUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]]; NSMut...

How to return an NSMutableArray from an NSSet

I'm able to put the contents of an NSSet into an NSMutableArray like this: NSMutableArray *array = [set allObjects]; The compiler complains though because [set allObjects] returns an NSArray not an NSMutableArray. How should this be fixed? ...

Preventing duplicate copies in a table view

I have an NSMutableArray that I display through a table view. The problem is that when I add objects to this array, I don't want to have duplicates. If I create an NSMutableSet from the NSMutableArray, then add objects to the NSMutableSet and then convert it back to an NSMutableArray, is that any more efficient than checking the NSMutab...

is it possible to save NSMutableArray or NSDictionary data as file in iOS ?

i want to save NSMutableArray or NSDictionary to save as file and close application. then reopen application and read some data from that file to use. is it possible? ...

iPhone: Return NSMutableArray in method while still releasing

I am trying to understand a little more about memory management. Knowing that I need to release anything that I have init or alloc'ed I am confused about the following: - (NSMutableArray *)getData { NSMutableArray *data = [[NSMutableArray alloc] init]; NSString *first = @"First object"; [data addObject:first]; NSString ...

How to sort an array of an array of objects by those objects attributes

If have an NSMutableArray foo of an NSMutableArray bar of objects. Each of the objects have a property that is a numerical value. In each NSMutableArray bar I want to sum this numerical property of each object. Then I want to sort the NSMutableArray foo by this sum. What's a good way to do this? ...