nsmutablearray

How to assign values from NSMutableDictionary to NSArray

我们两清 提交于 2019-11-28 13:58:54
问题 I am doing JSON parsing and I want to show my parsed data in a UITableView . For that, I am trying to assign parsed data from NSMutableDictionary to NSArray to show in the table view but the array returns null . Here my array returns null value; NSMutableDictionary *tempDict1; NSArray *arr = [[tempDict1 valueForKey:@"rates"] componentsSeparatedByString:@";"]; code - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *responseString = [[NSString

How to Print out(NSLog) the properties of a custom object added to a NSMutableArray

感情迁移 提交于 2019-11-28 13:22:42
I have a custom object that I create with 3 properties defined in it. I create the object and assign the values to those properties. After that I put that object into an NSMutable Array . I know I can use : for (id obj in personArray) { NSLog(@"obj: %@", obj); } NSLog(@"%@", personArray); To tell me what kind of objects are in my array. But I want to go a level deeper, I want to be able to see what the properties are for each of those objects. I'm just not sure how to target them. Here is the code and I am using: Person is my custom object. personObject = [[Person alloc]init]; [personObject

Why can't I return an object from my block?

拟墨画扇 提交于 2019-11-28 13:08:23
I'm trying to return a NSMutableArray from my block in my method, but when I add the line return [responseString JSONValue]; , I get some compiler warnings. - (NSMutableArray*)getTodayData:(NSDate*)today { ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; [request setPostValue:[dateFormat stringFromDate:today] forKey:@"target_date"]; NSError *error = [request error]; [request setCompletionBlock:^{ NSString *responseString; if (!error) { responseString = [request responseString]; return [responseString JSONValue]; } else { NSLog(@"error: %@", error); } }]

NSCFString countByEnumeratingWithState:objects:count: ERROR while searching NSMutableArray

一个人想着一个人 提交于 2019-11-28 12:59:05
I have the following situation where I have an NSMutableArray filled with an xml file which I want to search. When I enter something in the search field I get this Error: -[NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x5b388b0 What does it means and how can I fix it?? I suppose the error is somewhere around here. - (void)searchTableView{ searchedList = [[NSMutableArray alloc] init]; NSLog(@"new list %@", searchedList); NSString *searchText = searchBar.text; NSMutableArray *searchArray = [[NSMutableArray alloc] init]; for (NSDictionary

Random number without repeating

自闭症网瘾萝莉.ら 提交于 2019-11-28 12:51:50
问题 I have NSMutableArray with 50 array elements. I need to generate randomly without any repetition. Can you suggest some sample codes. 回答1: here is sample to get random int less than 1000. int y = arc4random() % 1000; to stay without duplicates, just check before inserting 回答2: Create a local mutablearray copy of main array, and after getting random value, remove object available at random index from local array, process it till array count is 1. 回答3: I have assumed you want to generate numbers

Swift - Cast Int64 to AnyObject for NSMutableArray

不羁的心 提交于 2019-11-28 12:27:35
Hi I have a NSMutableArray and I try this: var ma = NSMutableArray() let number:Int64 = 8345834344 ma.addObject(number)// Error "Type Int64 does not conform to protocol AnyObject" How to add Int64 variable to NSMutableArray() ? You are using a Foundation array (NSMutableArray), so you should use a Foundation number object: ma.addObject(NSNumber(longLong:number)) You could also use a native swift array: var ma = [Int64]() ma.append(number) Like so much of Swift, this is implemented in Swift. So you can do this (or the equivalent for the types you want) which will magically make it possible to

Can i have a single NSMutableArray in my multiple views application?

≯℡__Kan透↙ 提交于 2019-11-28 12:25:30
问题 I have a navigational based application which has multiple views. Is it possible to use one single NSMutableArray for the whole applicaiton? Can i add objects to that NSMutableArray in one view and then remove object from the same NSMutableArray from some other view? I tried myappAppDelegate *appDelegate = (myappAppDelegate *)[[UIApplication sharedApplication] delegate]; but it gives me null when i try to access appDelegate's array. If anyone can give me any idea or helping link or tutrorial.

iPhone - Crash using addObject on a NSMutableArray

依然范特西╮ 提交于 2019-11-28 11:36:56
I have a problem here. Or Maybe I'm really tired... I have a class : @interface THECLASS : UIViewController <UITableViewDelegate> { NSMutableArray* param; } @property(nonatomic, retain) NSMutableArray* param; Inside that class I have a method that is called when the user clicks on a UISwitch inside a tableViewCell (I build the params into a IBAction method that is not shwon here) : @synthesize param; - (void) changedSelectorValue:(NSIndexPath*)indexPath isOn:(BOOL)isOn { [self.param addObject:@"eeeee"]; } This crashes the app with the following log : 2011-02-04 01:31:02.548 Learning Project

Objective-C : Sorting NSMutableArray containing NSMutableArrays

。_饼干妹妹 提交于 2019-11-28 11:29:07
I'm currently using NSMutableArrays in my developments to store some data taken from an HTTP Servlet. Everything is fine since now I have to sort what is in my array. This is what I do : NSMutableArray *array = [[NSMutableArray arrayWithObjects:nil] retain]; [array addObject:[NSArray arrayWithObjects: "Label 1", 1, nil]]; [array addObject:[NSArray arrayWithObjects: "Label 2", 4, nil]]; [array addObject:[NSArray arrayWithObjects: "Label 3", 2, nil]]; [array addObject:[NSArray arrayWithObjects: "Label 4", 6, nil]]; [array addObject:[NSArray arrayWithObjects: "Label 5", 0, nil]]; First column

Mutable Objects inside NSUserDefaults

不问归期 提交于 2019-11-28 11:17:09
问题 I created a simple database and put in NSUserDefaults. My database is NSMutableArray which has dictionaries and arrays inside in it. When I create NSMutableArray from NSUSerDefaults I can't add any objects to my mutable objects inside my NSMutableArray. Here is my code: NSMutableArray *arrayOne = [NSMutableArray arrayWithContentsOfFile:[self createEditableCopyOfIfNeededWithFileName:@"Form.plist"]]; NSUserDefaults *ayarlar = [NSUserDefaults standardUserDefaults]; [ayarlar setObject:arrayOne