nsmutablearray

Proper way to copy a readonly NSMutableArray

I have an object with a readonly property that I am trying to implement NSCopying for. It has a mutableArray called "subConditions" (which holds "SubCondition" objects). I have made it readonly because I want callers to be able to change the data in the array, but not the array itself. This worked really well until it was time to write ...

NSMutableArray filled with pointers

I know this question was already asked in the past, but i am really confused and can't get out of it. i have got 9 pointers to IB objects declared like: IBOutlet UIButton *but1; IBOutlet UIButton *but2; .... NSMutableArray *buttons; declared properties: @property (nonatomic,retain) IBOutlet UIButton *but1; ...

Adding nil to NSMutableArray

I am trying to create a NSMutableArray by reading in a .txt file and am having trouble setting the last element of the array to nil. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"namelist" ofType:@"txt"]; NSString *data = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; NSArray *list...

iphone NSMutableArray loses objects at end of method

Hello - in my app, an NSMutableArray is populated with an object in viewDidLoad (eventually there will be many objects but I'm just doing one til I get it working right). I also start a timer that starts a method that needs to access the NSMutableArray every few seconds. The NSMutableArray works fine in viewDidLoad, but as soon as that m...

Object in Array is not recognised as having "methods"

I got my application working Awhile back, but after completely and accidentally deleting it, I have tried to create it from square one. unfortunately my rewritten program is a bit cranky; does anyone see or know the possible sources of error? Also, my if statements are acting up. -(void)loadAnnotations { CLLocationCoordinate2D worki...

NSMutableArray & Multiple Views

I am trying to write an application that has a NSMutableArray that needs to be accessed and modified in a different View. The MainViewController displays a table that gets the information from an NSMutableArray. The SecondaryViewController is used to addObjects into the array. How do I go about this without declaring it as a global var...

Can get members, but not count of NSMutableArray

I'm filling an NSMutableArray from a CoreData call. I can get the first object, but when I try to get the count, the app crashes with Program received signal: “EXC_BAD_ACCESS”. How can I get the count? Here's the relevant code - I've put a comment on the line where it crashes. - (void)viewDidLoad { [super viewDidLoad]; managedObjec...

Can't add to NSMutableArray from SecondaryView

Hi guys, I've searched and read and still haven't found a concrete answer. Brief: I have an application where I declare an NSMutableArray in my AppDelegate to synthesize when the application loads. (code below). I have a SecondaryViewController call this function, and I have it output a string to let me know what the array size is. Ev...

Issues declaring already existing NSMutableArray in new class

I have a class (DataImporter) which has the code to download an RSS feed. I also have a view and separate class (TableView) which displays the data in a UITableView and starts the parsing process, storing parsed information in an NSMutableArray (items) which is located in the (TableView) subclass. Now I wish to add a UIMapView which dis...

Method in RootViewController not Storing Array

I have an array initialized in my RootViewController and a method that addsObjects to an array. I created a RootViewController object in my SecondViewController. The method runs (outputs a message) but it doesn't add anything to the array, and the array seems empty. Code is below, any suggestions? RootViewController.h #import "RootVi...

iPhone app memory leak

Any idea why this code gives me a memory leak? As you can see, I'm running out of ideas as to what I can do to stop it. - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSArray *allSketches = [project.sketches allObjects]; NSMutableArray *temp = [[NSMutableArray alloc] initWithArray:allSketches]; ...

Replace an Array with an Array

I have and NSMutableArray and I want to replace it with another, but if I try to do it like this... firstArray = secondArray; ...then it seems to erase the entire firstArray and I get this error message.. Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0...

Where'd my sounds go?

In my Row class I have the initWithCoder method and everything restored in that method works fine, but only within the method. After the method is called I loose an array of sounds that is in my Row class. The sounds class also has the initWithCoder method, and the sound plays fine but only in the Row class initWithCoder method. After de...

Memory leak using NSMutableArray in RootViewController called from App Delegate

I've written code to restore the state of my app, but there's a memory leak in the NSMutableArray. I'm new to Xcode so I apologize if this is something trivial I have overlooked. Any help is appreciated. lq AppDelegate.m - (void)applicationDidFinishLaunching:(UIApplication *)application { [rootViewController restoreState]; } RootV...

How to check if a NSMutableArray contains a value (null) or not ?

Hi all, I have a NSMuatableArray object which contains "N" number of objects and i want to check wheather mutablearray contains (null) value or any othervalue. In NSString there is an method called isEqualToString: Wheather any simmilar method available for NSMutableArray? How can i do this? ...

Crash on replacing map annotations

Solved it, see below code I'm trying to replace annotations on my MapView depending on the distance between user location and annotation. The annotations are getting replaced like they should, but when I touch te mapview my app crashes. This is de code I have so far: NSMutableArray *tempArray = [[NSMutableArray alloc] init]; for (...

Can I store AVAudioPlayer references in an NSMutableArray and play them at will?

I have a library of 16 short sound clips I need to be able to play in quick succession. I realized that creating and preparing AVAudioPlayer objects in real time was too much to ask of the iPhone. So instead, during my app's initialization, I am pre-creating a series of AVAudioPlayers so that each one is basically pre-loaded with one...

NSMutableArray with Struct

Hi, i like to make an array out of an typedef struct i have. It works fine when i work with a FIXED array size. But just to be open for bigger arrays i guess i have to make it with nsmutable array. But here i dont get it run //------------ test STRUCT typedef struct { int id; NSString* picfile; NSString* mp3file; NSStri...

Save NSmutableArray to file and load

hello all , i am written app for my iphone and i want to save some NSmutablearray to file and load it later. i read about NSArchiver but didnt understand how to work with my calss is : @interface Shop : NSObject { NSString *m_Name; NSString *m_Description; NSString *m_Category; NSString *m...

NSNumbers in archived array dissappear.

Okay I've made an array of NSNumber objects that I've stored into an NSMutableArray. When the game loads it's unarchived and retained but all the NSNumber objects are gone. Here's my code: times = [[NSMutableArray alloc] initWithObjects:[[NSNumber alloc] initWithFloat:time],nil]; [NSKeyedArchiver archiveRootObject:times toFile:@"times"]...