nsarray

Compare two NSArrays and return number of differences

How can I take two NSArrays, compare them, then return the number of differences, preferably the number of different objects, for example: Array 1: one two three Array 2: two four one I would like that to return "1" ...

Limit to 10 number of annotations in mapkit!

Hi, I have all my annotations(as nsdictionnaries) in an array , and the users add them one by one by tapping on an icon. I want to make it impossible to add more annotations after adding 10 annotations (there is 110). Is it here i have to make something?: -(IBAction) plusButtonTapped: (id) sender { NSDictionary *poiDict = [poiArray ob...

Limit Annotation number in Mapkit

Hi all, I want to stop my app from loading more annotations after they are all added ( they are added by the user one by one), as the app otherwise crashes. How would you do that? the following code is what i think is important (void) loadAndSortPOIs { [poiArray release]; nextPoiIndex = 0; NSString *poiPath = [[NSBundle mainBundle] ...

Using NSPredicate to determine if a string equals another string.

I have a NSArray of CalEvents returned with the [CalCalendarStore eventPredicateWithStartDate] method. From the events returned, I am trying to keep only those in which the title of the event == @"on call" (case-insensitive). I am able to keep in the array those events whose title includes @"on call" with the following code (where event...

Getting unique items from NSMutableArray

Hi Guys, I have a question about Objective-C today involving NSMutableArray. Coming from a .net/c# background I'm having some trouble working with these things. Let's say I have an object called "Song" My song has 3 properties: Title Artist Genre I have a NSMutableArray or NSArray wich holds all my Song objects. How would I go ab...

Using CGPoints in an NSArray

I have been trying to create an array stating the location of a UIImageView in an app I've been working on. What I am trying to do is by using an array I can store the location of my "player" image by using its x,y and z coordinates. The script I am trying to accomplish would look like NSArray *location[3]; -(IBAction)startup;{ [locat...

array retain question

Hello, im fairly new to objective-c, most of it is clear however when it comes to memory managment I fall a little short. Currently what my application does is during a NSURLConnection when the method -(void)connectionDidFinishLoading:(NSURLConnection *)connection is called upon I enter a method to parse some data, put it into an array, ...

My NSMulipuleArray donesn't have objects

Hi, I am simply trying get the objects in my DB using an Array ie display the search results in another viewcontroller. I think the problem it that I am not linking the delegate to the controller and as a result my Array is not reading the objects when I put my sql statement in.... Here's what it looks like? + (void) getInitialDataToDi...

Efficient method of getting all plist arrays into one array?

If I have a plist which is structured like this: Root Array Item 0 Dictionary City String New York People Array Item 0 String Steve Item 1 String Paul Item 2 String Fabio Item 3 String David Item 4 String Penny ...

Best way to save to nsuserdefaults for custom class?

If I have a custom class Person which has three variables (which are propertized and synthesized): NSString* theName; float* theHeight; int theAge; Person instances are stored in an NSArray 'Group'. There is only one Group. What is the best way of storing and loading the Group in NSUserDefaults? (bearing in mind that float and int are...

NSArray writeToFile fails

Hi I am trying to save an array, which has some dictionaries inside, to a plist file but it fails. I don't get any errors. I do exactly the same few lines above in the code just with another array and that works.. I can't figure out why it does not save the file. This is where I save the file: (see some debugger output below) // When ...

Finding out whether an object exists within a plist?

If I have a plist which I have put into and array, which looks something like this -Root -Item 0 Dictionary Name String Henry Kids Array -Item 0 String Lindy -Item 1 String Paul -Item 1 Dictionary Name String Janet Pets ...

iPhone / NSArray : How do I format a text file to be read in using arrayWithContentsOfFile

I have several large word lists and I had been loading them in place in the code as follows: NSArray *dict3 = [[NSArray alloc] initWithObjects:@"abled",@"about",@"above",@"absurd",@"absurdity", ... but now it is actually causing an exc_bad_access error weirdly, i know it seems implausible but for some reason IT IS causing it. (trust m...

getting plist from documents directory instead of Bundle

I'm trying to point to the documents directory instead of the Bundle, I have the following code: - (id)initWithLibraryName:(NSString *)libraryName { if (self = [super init]) { libraryPlist = libraryName; libraryContent = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] ...

Objective-C/cocoa losing array values

I have multiple arrays, however, they are not retaining their data for use in another method. Here's how I have it set up (simplified) .h NSArray *array; @property (nonatomic, copy) NSArray *array; -(void)someMethod:(NSArray*)someArray; -(void)heresNewMethod; .m -(void)someMethod:(NSArray*)someArray { array = [someArray copy]; } ...

How to search an NSSet or NSArray for an object which has an specific value for an specific property?

How to search an NSSet or NSArray for an object which has an specific value for an specific property? Example: I have an NSSet with 20 objects, and every object has an type property. I want to get the first object which has [theObject.type isEqualToString:@"standard"]. I remember that it was possible to use predicates somehow for this ...

Finding maximum numeric value in NSArray

I have an NSArray of NSNumbers and want to find the maximum value in the array. Is there any built in functionality for doing so? I am using iOS4 GM if that makes any difference. ...

NSMutableSet and NSArray sorting, how to keep them consistent?

I'm trying to make an array of objects in random, non repeating order. Using NSMutableSet for the heavy lifting as recommended here: http://stackoverflow.com/questions/2141121/how-to-check-repetition-of-numbers-in-an-array I'm dumping them into an NSArray after creation to access them, but the NSArray doesn't stay in the order I placed ...

EXC_BAD_ACCESS NSArray of ManagedObjects (Core Data)

Something strange is going on with my iphone app. I am using Core Data to store data in a SQLite database. The first time after my app starts up I try to read a table to return all of the rows to fill a UITableView with a list of things for the user to select from. If they chose the top item in the list I get a EXC_BAD_ACCESS exception. ...

objective-c nsarray to c array

Sorry, I'm not even sure how to ask, since I'm a complete newbie at C, pointers and stuff like that. There's a function that accepts an argument: char **arg. If I write that argument like so: char *cargs[] = {"blah", NULL}; and pass it to the function: function(cargs); it works. but ... I have an NSArray of NSStrings and I need to ...