nsarray

How to properly pass NSArray / NSMutableArray from one UIViewController to another ...

An iphone app I'm working on is terminating periodically ... and I have a feeling it is because of how I'm accessing a shared NSArray amongst several view controllers. So ... What is the best way to pass NSArray/NSMutableArray amongst several ViewControllers ... all of which can modify and/or set it to nil or whatever? Thanks ...

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...

NSArray multiply each argument

Is the there a way to multiply each NSNumber contained in the array by 10? Here is what I have so far: NSMutableArray *vertex = [NSMutableArray arrayWithCapacity:3]; [vertex addObject:[NSNumber numberWithFloat:1.0]]; [vertex addObject:[NSNumber numberWithFloat:2.0]]; [vertex addObject:[NSNumber numberWithFloat:3.0]]; [vertex makeObje...

App crashes when using international characters in NSDictionary

I am listing out data to a UITableView from a plist file where I have a two dimensional array/dictionary: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; <plist version="1.0"> <array> <dict> <key>ID</key> <integer>1</inte...

iPhone - Merge keys in a NSArray (Objective-C)

Hi everyone, I'm having troubles with arrays and keys... I have an array from my database: NSArray *elementArray = [[[menuArray valueForKey:@"meals"] valueForKey:@"recipe"] valueForKey:@"elements"] The problem here is that I would like all my elements of all my meals of all my menus in an array such that: [elementArray objectAtIndex:0...

extract data from Plist to array and dictionary

Hi I made a plist that looks like that: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList 1.0.dtd"> <plist version="1.0"> <array> <array> <dict> <key>Company</key> <string>xxx</string> <key>Title</key> <string>VP Marketi...

NSArray from NSSet - Do I have to sort it myself?

I've got data in an NSSet, and I need to get it into an NSArray. Do I need to sort it myself (again, this came from Core Data) or can I get it out in a sorted order? ...

Storing arrays in NSUserDefaultsController

Currently I use NSUserDefaults and I'm interested in using NSUserDefaultsController, so that I get notifications when things change. Below is my current code. items = /* NSArray of MYItem's */; NSData* data = [NSKeyedArchiver archivedDataWithRootObject:items]; [[NSUserDefaults standardUserDefaults] setObject:data forKey:kMYItems]; Ho...

Altering ManagedObjects In NSArray

I have an entity called 'Job' with two boolean attributes named 'completed' and 'logged'. I am trying to retrieve all completed jobs that have not been logged at app start-up and change them to logged. I'm able to get all the completed but unlogged jobs with this fetchRequest: NSPredicate *predicate = [NSPredicate predicateWithFormat:@...

containsObject - why doesen't this work?

Hi. I have an array that I am trying to check wether or not an indexPath(.row) exists in. I use this code: if ([array containsObject:[NSNumber numberWithInt:indexPath.row]]){ NSLog(@"Yep, it exists in there."); } the array consist of the numbers 3, 8 and 2. The index path loads numbers fromm 0 to 8 in a loop. Can anybody see wh...

How do I add a CGPoint to NSMutableArray?

I want to store my CGPoint to the NSMultable Array, so , I have method like this: [self.points addObject:CGPointMake(x, y)]; But I got the error, it said that : Incompatible type for argument 1 of "addObject". So, I check out the API, (void)addObject:(id)anObject anObject The object to add to the end of the receiver...

Fetching Core Data for Tableview on iPhone - Tutorial leaves me with crashes when adding items to a list

Been following the Core Data tutorial on Apple's developer site, and all is good until I have to add something to the fetched store. I am getting this error after a successful build and load when I try to add a new item to the list: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update:...

NSDictionary, NSArray, NSSet and efficiency

Hi, I've got a text file, with about 200,000 lines. Each line represents an object with multiple properties. I only search through one of the properties (the unique ID) of the objects. If the unique ID I'm looking for is the same as the current object's unique ID, I'm gonna read the rest of the object's values. Right now, each time I s...

Problems with makeObjectsPerformSelector inside and outside a class?

A friend and I are creating a card game for the iPhone, and in these early days of the project, I'm developing a Deck class and a Card class to keep up with the cards. I'm wanting to test the shuffle method of the Deck class, but I am not able to show the values of the cards in the Deck class instance. The Deck class has a NSArray of Car...

NSObject release destroys local copy of object's data

I know this is something stupid on my part but I don't get what's happening. I create an object that fetches data & puts it into an array in a specific format, since it fetches asynchronously (has to download & parse data) I put a delegate method into the object that needs the data so that the data fetching object copies it's formatted a...

JsonDebgingProblem

i have one issue.. Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘* -[NSCFArray objectForKey:]: unrecognized selector sent to instance 0*c3e6afe0’ stack(29365339.7657656....); please help issue.. ...

NSArray vs. SQLite for Complex Queries on iPhone

Developing for iPhone, I have a collection of points that I need to make complex queries on. For example: "How many points have a y-coordinate of 10" and "Return all points with an X-coordinate between 3 and 5 and a y-coordinate of 7". Currently, I am just cycling through each element of an NSArray and checking to see if each element m...

How to let the sortedArrayUsingSelector using integer to sort instead of String?

I have some data like this : 1, 111, 2, 333, 45, 67, 322, 4445 NSArray *array = [[myData allKeys]sortedArrayUsingSelector: @selector(compare:)]; If I run this code, it sorted like this: 1, 111, 2,322, 333, 4445, 45, 67, but I actually want this: 1, 2, 45, 67, 111, 322, 333, 4445 How can I implement it? thz u. ...

NSArray filled with bool objects

I have an NSArray filled with bools (expressed as a number), and I need to test to see if any object within the array is equal to 1. How can I do it? ...

How to make an C vector or array from an NSArray?

Is that possible? I've seen no method that would generate a plain old C vector or array. I have just NSNumber objects in my array which I need as C vector or array. ...