nsmutablearray

Attempt to insert nil

Seems like it should be easy to add a boolean to an NSMutableArray. Assume toDoArray is intialized as an NSMutableArray. The following: BOOL checkBoxState = NO; [toDoArray addObject:checkBoxState]; Generates the error "attempt to insert nil." What's the correct way to add a negative boolean to a mutable array? ...

how to remove duplicate value in NSMutableArray

hi experts, i'm scanning wifi info using NSMutableArray, but there are few duplicate values appear, so i try to use following code but still getting the duplicate values, if([scan_networks count] > 0) { NSArray *uniqueNetwork = [[NSMutableArray alloc] initWithArray:[[NSSet setWithArray:scan_networks] allObjects]]; [scan_networks rem...

Memory leak in NSMutableDictionary, NSArray in NSXMLParser

I'm suffering from a bad memory leak parsing one of my xml documents. I'm using the NSXMLParser to iterate each node (album in the xml sample below), then iterate each photo node and add the result to an NSArray. I have 2 retained properties, which store two values on each loop. These values are added to a NSMutableDictionary object a...

UserDefaults/KeyedArchiver Frustrations

I'm working on a homework app that uses custom Assignment objects for each assignment. I am trying to store an NSMutableArray (casted to an NSArray via initWithArray:) in standardUserDefaults but I'm having trouble with saving and reloading the array. I have a table view from which you can choose to add a new assignment (which loads N...

Best way to sort NSMutableArray ?

I have an iPhone application that needs to sort a couple of NSMutableArrays, this arrays contain around 3000 elements. The idea is to sort them once when the application starts, then every iteration I need to insert 9 elements to each of those arrays. Is there an efficient way with NSMutableArrays, to insert those 9 elements in a sorted...

Remove objects from NSMutable array that match with objects from another NSMutable Array

Ok so: i have NSMutableArray 1 i also have NSMutableArray 2 I would like to remove all objects from array 1 that match with objects in array 2. Any ideas? Thanks! ...

Share didSelectRowAtIndexPath selection in an array, between 2 controllers

On my never ending quest to share a table row selection to multiple views loaded in a modal view, I have got it down to one issue. I am using Apples DrillDownSave sample code as a model to recreate this magic. And think I have it all set up exactly the same... In the didSelectRowAtIndexPath section of my RootViewController.m, I have the...

Sorting Numbers ins a Object.

Hi I have an NSMutableArray of objects, let's say 'Person' Objects. I want to sort the NSMutable Array by person.savings i.e if suppose person having savings 1000,1050,500,1200,2000,1050 i want the Array in the ascending order. Thank You. ...

NSMutableArray Description Method - Array of Arrays

I have an Array that contains array objects. An array of Arrays. When I apply the description method to the Array, I don't see the data in the inner arrays. Here is the code: [runScoreDataArray addObject:[NSString stringWithString:currentUser]]; [runScoreDataArray addObject:[NSNumber numberWithDouble:mainScores.scoreTotal]]; NSLog(@"Ar...

replaceObjectAtIndex array problems

Been searching for the answer to this for a while now and I think due to the nature of my array set up, I may be searching for the wrong answer! I have a class which handles adding items to my array: // Item.h @interface Item : NSObject { NSString *name; NSNumber *seconds; } @property(nonatomic,copy) NSString *name; @property(...

How to addObject of NSMutableDictionary to NSMutableArray in a loop

Hi all, I'm having difficulty to add a data structure to an array to create an array of dictionaries from a loop. I just knew that addObject in NSMutableArray only add pointer to it. I would like to know how to achieve my goal. Here's my code: NSMutableDictionary *woRows = [[NSMutableDictionary alloc] init]; NSMutableArray *workOrders...

NSMutableArray and property leaking memory

Hi all, I am in memory-leak cleanup mode on my latest app, and have come across something that I am unable to solve. the following method has been cleaned up except for 1 nagging issue. Instruments tells me that my NSMutableArray called itemsToKeep is leaking memory, at the point that I am creating the object. Any ideas on why I am leak...

Need help with iphone sdk: not correctly saving .plist to documents directory

I've been spending way too long trying to figure out what is going wrong, so I hope someone her can help me out. My Code: - (IBAction)fedDog { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documen...

NSArray of UIBarButtonItem Tag (i.e. NSInteger)

Is it true that you can't have an NSMutableArray of NSIntegers? When I try to add the values to the array and then print them out they're huge numbers (when if I print out the tag to NSLog they're 0,1,2,3 etc.). I'm trying to create an array of my UITabBarItem's tags so I can save the order and retrieve it later. Am I forced to do some ...

iPhone SDK: How do I properly save user-inputted information into a .plist or other file?

I've looked through the SDK documentation and through other questions that have been asked, and I am still a little confused on how exactly to do this. I had been previously been working with the following code, though it does not give the desired result of a .plist file. Besides mentioning the IBAction in the header files in this code...

Show more than one Object in a NSTableView row

Hi, I'm new here at stackoverflow :) But I think, this is the right place to ask my question. I'm a new developer with Cocoa and Objective-c & I'm trying to write my first App for Mac: a ToDo App. At this moment, i can save ToDo's and delete them, but now, I want to add some features like CreationDate, some Tags (in mutablearray), and i...

removeObjectAtIndex without releasing the object

Hi, I have a mutable array and i would like to arrange it in a nested order upon some criteria. To achieve this I'd like to move certain elements to mutable arrays of another elements, removing them from the main mutable array, but without releasing them. Actually the question is about removing elements from array without releasing them...

Copy & mutableCopy?

What is the difference between the "copy" & "mutableCopy"? EDIT_001: My original post was a bit of a mess, partly due to a lack of understanding and partly due to a bit of pilot error on my part. Here is my attempt to better explain how "copy" & "mutableCopy" work. // ** NSArray ** NSArray *myArray_imu = [NSArray arrayWithObjects:@...

Cocoa Array of Objects to String

Hey there, I have an NSMutableArray of objects. Each object has a property called "Name". I want to join them together in a string with a separator " > ". So if the name property in each of the objects in my array is "one", "two" and "three" respectively, the result would be "one > two > three". Thanks, howie ...

Reusing objects in loop when adding to an NSMutableArray

When adding objects to an NSMutableArray in a loop, what are some best practices as to reuse memory allocated for objects that are to be added to the array? For example: for (int i = 0; i < 5; i++) { SampleObject *sampleObject = [[SampleObject alloc] init]; sampleObject.someProperty = ... [sampleObjectArray addObject:sampl...