nsarray

How to save Data in text file when user chooses a button

I want to have user select between two different buttons on a view, If the the user selects the imageOne, a label is created called "imageOne", then I'll save the label into an array using the following technique: - (IBAction)saveData { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)...

How to keep an NSArray available to all methods when programming for the iPhone.

Hello. I am making an iPhone app that uses a few NSArrays. Right now I have to generate the arrays in each method. I know there has to be an more efficient way of doing this, like having the NSArrays created during initialization and then being available to all methods after that. The problem is, that when I create the NSArrays in th...

tabBarController memory leak

In my AppDelegate I initiate a tabBar Controller, to which a bunch of navigationController is added as tabs. I use the following code: // Init tabBar Controller tabBarController = [[[UITabBarController alloc] init] retain]; // Init Root Views of navigation controllers FirstRootViewController* firstViewController = [[[FirstRootViewContr...

NSString Value of NSArray Object

I'm trying to figure out why this code doesn't work. I'm trying to search if a string contains "|P". If it does, I want to do something. NSMutableArray *list = [pView getPOIList]; NSString *cellValue = [list objectAtIndex:indexPath.row]; cell.textLabel.text = cellValue; NSArray *chunks = [cellValue componentsSeparatedByString: @"|P"];...

I can't fill the cells of my UITableView with a NSArray (Normally it always works, but not in the case)

Hello, I have a UITableView with Cells that are filled with the Objects of an NSArray. I´m using the MGTwitterEngine to get Tweets from users. I want to show this tweets in the TableView. Here is the method that is called when the MGTwitterEngine has received all tweets ("namen" and "nachricht" are NSArrays): - (void)statusesReceived:(N...

Xcode warning: "NSArray may not respond to -addObject"

In my header file, I have this code: @interface TableViewController : UIViewController { IBOutlet UITableView *tblListData; NSArray *arryData; } In my class declaration file, I have this implementation: - (void)viewDidLoad { arryData = [[NSArray alloc] initWithObjects:@"iPhone",@"iPod",@"MacBook",nil]; [super viewDi...

Why can I fill my NSArray just with one object?

Hello, why can´t I fill my NSArray? Where is my mistake? He always just fill one object/image to the nsarray. I set a NSlog to check which value string has and he shows me all the 20 urls. for (int i = 0, count = [bild count]; i < count; i = i++) { NSString * string = [bild objectAtIndex:i]; NSURL *url = [NSURL URLWithString:str...

NSArray sort and isolate

I have an NSArray of names, I want to sort them alphabetically into a UITableView and separate them into sections. I have a tagged section at the top, being section 0. I want the names sorted aplhabetically to come after that. So all names beginning with A get put into section 1, B into section 2, and so on. I need to be able to someho...

I want to merge two object either in an array or prior to saving

I am saving the first and last name from ABpeoplepickerNavcontroller, I would like to merge the first and last name prior to saving into an array so that when i retrieve it, they would be together. The first code is the object being created: // setting the first name firstName.text = (NSString *)ABRecordCopyValue(person, kABPersonFirstN...

reading an array

I create random numbers using the following code and store them in an array. NSMutableSet *aSet = [NSMutableSet setWithCapacity:6]; while([aSet count]<=6){ int Randnum = arc4random() % 12; [aSet addObject:[NSNumber numberWithInt:Randnum]]; } NSArray *arrayOfUniqueRandomNumbers = [aSet allObjects]; Now, I need to read the ...

Maximum amount of objects in NSArray

What is the largest amount of objects I can put in my NSArray? ...

Cocoa Webkit bug?

I have some code that gets the URL from an array and stores it as a string then uses that string to load up the URL. NSString *first = [urls objectAtIndex:[sender clickedRow]]; NSLog(@"%@", first); [[webview mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:first]]]; However, when I run this I get this error: -...

Help sorting an NSArray across two properties (with NSSortDescriptor?)

I'm a bit of a NSSortDescriptor n00b. I think, though, it is the right tool for what I need to do: I have an NSArray consisting of objects with keys, say, "name" and "time". Instead of verbalizing it, here's an example: input: name: time B: 4 C: 8 B: 5 C: 4 A: 3 C: 2 A: 1 A: 7 B: 6 desired output: name: time A: 1 <--- A: 3 A: 7 C: ...

How to Get the Direct Access Index for NSDictionary of NSDictionary

Here's the code: NSMutableDictionary *circuit_step = [NSMutableDictionary dictionary]; NSMutableDictionary *step_info = [NSMutableDictionary dictionary]; [step_info setObject: @"search" forKey: @"search-type"]; [step_info setObject: @"small" forKey: @"search-format"]; [step_info setObject: @"winter" forKey: @"...

How can I modify a CGRect stored as NSValue in an NSArray?

Hello, I am creating an NSArray with CGRects using the following line: [self setMyArray:[NSArray arrayWithObjects:[NSValue valueWithCGRect:CGRectMake(x,y,z,a)], [NSValue valueWithCGRect:CGRectMake(x,y,z,a)], nil]] I am then trying to update the CGrects in the Array every so often like this: for (NSValue *bound in myArray) { CGR...

iphone large NSArray of strings performance woes

I have an Iphone app with a large, nested NSArray of strings. The NSArray goes 3 levels deep, and there are a total of approximately 15,000 strings at the deepest levels. The vast majority of the strings have fewer than 20 characters. Every so often, my app hangs for a while, then resumes working after 5-25 seconds or so. This is obv...

How to print a single array element in Objective-C?

Hello, How to print a array element at particular index in Objective-C?My code looks like this, NSString *String=[NSString StringWithContentsOFFile:@"/User/Home/myFile.doc"]; NSString *separator = @"\n"; NSArray *array = [String componetntsSeparatedByString:separator]; NSLog(@"%@",array); I'm able to print full contents of array at o...

iPhone - NSDictionary to NSArray with preserved order

I've got a couple dictionaries in a property list, that make up a menu system for my game, like so: New game Easy Normal Hard Load game Recent Older Options Game Sound etc.. Each item in this list is a dictionary. I use UINavigationController and UITableViews to display this menu system. When an item is ch...

IPhone SDK removal of NSLog causes NSArray to be undeclared !

I have a working application I'm about to distribute and am tidying up NSLog statements in it. When I remove NSLog from from a "case" statement, the NSArray declared within the "case" statement errors as Expected expression before AND undeclared. Anybody any idea why this may be? This is happening on all case statements in my app where I...

Using filteredArrayUsingPredicate always returns an empty array for Core Data fetched objects.

I'm trying to use NSArray's filteredArrayUsingPredicate: method to filter an array of core data managed-objects. Here's an outline: NSArray *array = self.fetchedResultsController.fetchedObjects; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name contains[c] %@", searchString]; NSArray *filteredA...