nsarray

Challenging pList Iterating and NSDictionary problem

I have a pList file: Root - Dictionary categories - Array item 0 - Dictionary item 1 - Dict item 2 - Dict I load the file like so: -(void) loadCategories { // Loads the categories from the SymbolList.plist file NSString *file = [[NSBundle mainBundle] pathForResource:@"SymbolList" ofType:@"plist"]; NSMutab...

sorting mutable array in alphabatical order

Hi i am having a nsmutable array and in that nearly 50 -60 object having different names ,and can i sort this array in alphabatical order (Is it possible, How?) (is it a duplicate question ?) ...

What's making NSArray access so slow?

I'm working up a graphics effect for an iPhone app that simulates a low-res plasma effect from old demoscene days. I've got 600 squares on screen that are updating as fast as possible. Since I am using CoreGraphics (for now), I can get a very constant 11FPS with no freezing-- BUT when I try to add one simple NSArray lookup, the iPhone a...

How to sort an NSArray of objects by their class?

I have an NSArray of objects that all subclass with their different types from a more abstract class. I would like to sort the array by the object's class type. For example: NSArray with CLASSA CLASSB AND CLASS C subclassed from CLASSz myArray = {C, B, A} Sort myArray decending: {A, B, C} I see sort descriptors and that seems like i...

Detect changes in NSArray in ObjC

Hello, I need to detect change in NSArray object - that is if some object was added/removed to/from NSArray or was just edited in-place. Are there some integrated NSArray hash functions for this task - or I need to write my own hashing function for NSArray ? Maybe someone has different solution ? Any ideas ? Thanks. ...

How does the objective-c SBJson library map an array? (do you reccomend it?)

SBJsonParser *parser = [[SBJsonParser alloc] init]; NSMutableArray *componenti = [parser objectWithString:@"[\"Item1\",\"Item2\"]"]; NSAssert([componenti isMemberOfClass:[NSMutableArray class]],@"err"); This code gives me an assertion failed. What is wrong? The header file says: @brief The JSON parser c...

Find indices of duplicates in a NSArray

i have an array like [chapter,indent,left,indent,nonindent,chapter,chapter,indent,indent,left]; i need to find indexes of duplicates and also non duplicate elements . how to do this...........give some sample code or logic...... thanks in advance iam using objective c..... NSArray *myWords = [string componentsSeparatedByString:@...

Initializing multidimensional NSArray for iPhone devel

Hello, i'm starting in iPhone devel and i need to use a multidimensional array. I init it using: NSArray *multi=[NSArray arrayWithObjects:[NSMutableArray arrayWithCapacity:13], [NSMutableArray array],nil]; when i try to assign values to n-th cell like: [[multi objectAtIndex:4] addObject:@"val"]; App hangs because of index 4 b...

Remember Previous Output in a Random Array

I have an application with the following code listed below that displays random questions for the end user. I am trying to figure out how to have a user be able to go navigate backwards in an array that is displayed randomly. For instance, a user is going through the questions and accidentally advances past one and wants to go back, I ...

NSArray and bool values

Can an NSArray hold an array of bool values? The following code runs BOOL b = NO; NSMutableArray *array = [[NSMutableArray alloc] init]; [array addObject:[NSNumber numberWithBool:b]]; NSLog(@"value is %d", [array objectAtIndex:0] ); However, I don't get a value of 0 for NO as expected. Instead, this is what I get value is 3773...

multiple objects for a single index in an NSArray

Is it possible to store multiple objects for a single index in an NSArray? ...

NSDictionary sort by keys as floats

Hi there basically I have an NSDictionary with keys and values. The keys are all numbers, but at the moment they are strings. I want to be able to compare them as numbers in order to sort them. eg: If I have a Dictionary like this: { "100" => (id)object, "20" => (id)object, "10" => (id)object, "1000" => (id)object, } ...

NSDictionary split into two arrays (objects and keys) and then sorted both by the objects array (or a similar solution)

Hi there I have an NSDictionary. It has keys and objects. For the purposes of simplicity the keys are Question numbers and the objects are calculated Answer scores. Now how I did it before was that I set the answer score as the keys and the question numbers as the objects. This way I could get an array of allKeys from the dictionary, ...

Generating permutations of NSArray elements

Let's say I have an NSArray of NSNumbers like this: 1, 2, 3 Then the set of all possible permutations would look something like this: 1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1 What's a good way to do this in XCode? ...

Using NSMutableArray in a class

Whenever I try to add something to my array in the method nothing gets added to the array. I'm wanting it to when you press the button it will add a new object to the array. // JBNumberGeneration.h #import <Cocoa/Cocoa.h> @interface JBNumberGeneration : NSObject { IBOutlet NSTextField *displayLabel; int randNum; int level; int i...

How to change this so that it returns arrays

The following code works perfectly and shows the correct output: - (void)viewDidLoad { [super viewDidLoad]; [self expand_combinations:@"abcd" arg2:@"" arg3:3]; } -(void) expand_combinations: (NSString *) remaining_string arg2:(NSString *)s arg3:(int) remain_depth { if(remain_depth==0) { printf("%s\n",[s UTF8Stri...

How to return an NSMutableArray from an NSSet

I'm able to put the contents of an NSSet into an NSMutableArray like this: NSMutableArray *array = [set allObjects]; The compiler complains though because [set allObjects] returns an NSArray not an NSMutableArray. How should this be fixed? ...

Using JSON Framework on iPhone - HELP!

Currently I am using the following code to parse the JSON link sent. This is how I also send a GET call to the Google Reader API for an upcoming iPhone application of mine. - (NSArray *)subscriptionList { if(!cookies && [cookies count] == 0) { [self requestSession]; } NSString * url = @"http://www.google.com/reader/api/0/subscripti...

Storing different data types in a NSArray

I'm trying to store different data types in a NSDictionary to save in NSUserdefaults when the game terminates. I'm trying to store a char, 3 floats and a string, I keep getting a warning on the char and the floats and I cant seem to find the answer anywhere. 1)Do i even need to setup the arrays? 2) How do I store the different data types...

Conditionally populate an array from another array - objectiveC

I want to copy items from an array that are not 0 or @"" (depending if NSNumber or NSString). The following code, however, does not work. What am I doing wrong? for (int i=0; i < [logbookItems count]; i++) { NSLog(@"%@, %@, %@", [[[logbookItems objectAtIndex:i] objectAtIndex:1] class], [[logbookItems objectAtIndex:i] objectAtIndex:0...