nsmutablearray

Re-ordering a collection of UIView's based on their CGPoint

Hi all, I have a NSMutableArray that holds a collection of UIViewControllers Amongst other properties and methods an instance of each of the viewControllers are placed in a parent view The user will place these objects individually when desired to. So essentially I use - (void)addSubview:(UIView *)view when a new view is added to th...

What's safe to assume about the NSMutableArray / NSArray class cluster?

I know you shouldn't use this to decide whether or not to change an array: if ([possiblyMutable isKindOfClass:[NSMutableArray class]]) But say I'm writing a method and need to return either an NSMutableArray or an NSArray, depending on the mutability of possiblyMutable. The class using my method already knows whether or not it's accep...

How to swap values in NSMutableArray?

This piece of codes segment fault on me, any idea why? allButtons is a NSMutableArray, it contains 3 objects, a=0, b=1, a and b are int type if(a != -1 && b!= -1){ //Swap index in "allButtons" id tempA = [allButtons objectAtIndex:a]; id tempB = [allButtons objectAtIndex:b]; [allButtons replaceObjectAtIndex:a withObject:...

Application crashes after when array of images are stored

Hi, I'm getting the screenshots from the following code: CGImageRef cgScreen = UIGetScreenImage(); if (cgScreen) { UIImage *result = [UIImage imageWithCGImage:cgScreen]; CGImageRelease(cgScreen); return result; } I'm calling the above code in a timer of 1/1.0 seconds as: [array addObject:[UIImage image...

Ordering a list of NSStrings in NSMutableArray?

Is it possible to order an NSMutableArray where it's values are NSStrings? I'm looking to order alphabetically. Thanks ...

How to search through a NSMutableArray

I have a NSMutableArray that I need to search for a string and return the key in the array where the string was found. So for example if I'm searching "ipod" and it's the 4th in the array, it would return 3 or whatever position the string is in. What's the best way to do this? ...

NSMutableArray withObject(UIImageView *)

I am trying to load an NSMutableArray with UIImageViews. Everything is going fine with that. Unfortunately, I have no idea how to use the objects when they are in the mutable array. Here is some code: UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; NSMutableArray *array = [NSMutableArray new]; [array loadWithObjec...

How to add numbers in a mutable array in iphone?

I am new to iphone development.I want a Nsmutable array to hold numbers from 1 to 100.How i can do it.how can i implement in a for loop.Is there any other way to hold numbers in array in iphone.Please help me out.Thanks. ...

NSMutableArray count method show the NSMutableArray is count 0?

This is my init method: -(id)init{ self = [super init]; magicNumber = 8; myMagicArray = [[NSMutableArray alloc] initWithCapacity:(magicNumber*magicNumber)]; NSLog(@"this is the magic Array: %d", [myMagicArray count]); return self; } This is the .h: @interface Magic : NSObject { NSMutableArray *myMagicArray;...

NSMutableArray of Objects

First off I am very new to Objective C and iPhone programming. Now that that is out of the way. I have read through most of the Apple documentation on this and some third party manuals. I guess I just want to know if I'm going about this the correct way ... - (NSMutableArray *)makeModel { NSString *api = @"http://www.mycoolnewssit...

What is the difference between these two different lines of Objective-C, and why does one work and not the other?

If I try and release tempSeedsArray after seedsArray = tempSeedsArray , I get an EXEC_BAD_ACCESS, and Instruments shows that tempSeedsArray has been released twice. Here is my viewWillAppear method: - (void)viewWillAppear:(BOOL)animated { NSString *arrayFilePath = [[NSBundle mainBundle] pathForResource:@"SeedsArray" ofType:@"pli...

NSMutableArray EXC_BAD_EXCESS SIGBUS

Hi, I've the following code which causes crashes after sometime as i've set the below code in a timer: CGImageRef cgImage = UIGetScreenImage(); [array addObject:(id)cgImage]; CGImageRelease(cgImage); Where initiallly i've declared array as: array = [[NSMutableArray alloc] init]; The timer goes well till 10 seconds as timer is of 1/...

Pass NSMutableArray between two UIViewController's

I have two view controllers name RootViewController and SecondViewController. In the FirstViewController I have this NSMutableArray @interface RootViewController : UITableViewController { NSMutableArray *allClasses;}@property (nonatomic,retain) NSMutableArray *allClasses; In the RootViewController I populate the UITableView with all ...

About NSMutableArray objectAtIndex...

Is the objectAtIndex start with 1 instead of 0? I use the objectAtIndex , and passing data 0, but it said that this is out of bound. So, I guess that is start at 1, am I right? ...

NSArray/NSMutableArray : Passed by ref or by value???

Totally confused here. I have a PARENT UIViewController that needs to pass an NSMutableArray to a CHILD UIViewController. I'm expecting it to be passed by reference so that changes made in the CHILD will be reflected in the PARENT and vice-versa. But that is not the case. Both have a property declared as .. @property (nonatomic, ret...

how do we access values stored in NSMutableArray of NSMutableDictionary ?

I have stored values in NsMutableDictionaries . ThenI stored all the dictionaries in NSMutable Array. I need to access the values ? How can I do that ? -(void)viewDidLoad { [super viewDidLoad]; self.title = @"Library"; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButton...

Can a function return an object? Objective-C and NSMutableArray

I have an NSMutableArray. It's members eventually become members of an array instance in a class. I want to put the instantiantion of NSMutable into a function and to return an array object. If I can do this, I can make some of my code easier to read. Is this possible? Here is what I am trying to figure out. //Definition: function Obje...

iPhone: Using a NSMutableArry in the AppDelegate as a Global Variable

What i'm trying to accomplish is to have an NSMutableArray defined in the AppDelegate. I then have two UIViewControllers. One view is responsible for displaying the array from the AppDelegate. The other view is used to add items to the array. So the array starts out to be empty. View1 doesn't display anything because the array is empty. ...

Sending array through email on iphone

Hey guys I need to send the content of an NSMutableArray through email. I have a mailing function but I'm not sure on how to place the content of the array into a NSString to be displayed on the email under each other. Is there a way to place all the content of the array into the string with maybe HTML nextline command between each array...

Grouping data in an NSMutable array

Hi guys, I have an array i load with lots of data from an xml file. I am displaying this on a tableview and then when you click on say an author it goes through to display all their books. At the minute my NSMutableArray has an entry for every each book with title, author and so on. So in the table of authors it display the authors name...