nsmutablearray

NSMutableArray initWithCapacity nuances

不打扰是莪最后的温柔 提交于 2019-12-27 20:14:54
问题 Does anyone have advice on how to best initialize an NSMutableArray when it comes to dictating the capacity? The documentation mentions that "...even though you specify a size when you create an array, the specified size is regarded as a “hint”; the actual size of the array is still 0." So... 1) If I init with a greater capacity than I typically use, do I not have to worry about wasted memory? 2) If I init with a capacity typically lower than what I use, do I have to worry about heavier

NSMutableArray initWithCapacity nuances

自古美人都是妖i 提交于 2019-12-27 20:08:29
问题 Does anyone have advice on how to best initialize an NSMutableArray when it comes to dictating the capacity? The documentation mentions that "...even though you specify a size when you create an array, the specified size is regarded as a “hint”; the actual size of the array is still 0." So... 1) If I init with a greater capacity than I typically use, do I not have to worry about wasted memory? 2) If I init with a capacity typically lower than what I use, do I have to worry about heavier

How to save NSMutablearray in NSUserDefaults

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-27 16:40:32
问题 I have two NSMutableArray 's. They consist of images or text. The arrays are displayed via a UITableView . When I kill the app the data within the UITableView gets lost. How to save array in UITableView by using NSUserDefault ? 回答1: Note: NSUserDefaults will always return an immutable version of the object you pass in. To store the information: // Get the standardUserDefaults object, store your UITableView data array against a key, synchronize the defaults NSUserDefaults *userDefaults =

Unable to retrieve NSMutableArray from NSUserDefaults

笑着哭i 提交于 2019-12-25 14:48:11
问题 I have an issue persisting data in local storage for an NSMutableArray containing a list of NSStrings. I have a save method and a get method both appear to work when the app is running. However, once I close the app and restart the items in the array are gone. NSMutableArray*ImageTags; Get Data -(NSMutableArray*)GetDataNSMutableArray:(NSString*)ItemName { NSMutableArray *GetData = [[NSMutableArray alloc] init]; NSUserDefaults *currentDefaults = [NSUserDefaults standardUserDefaults]; NSData

Passing NSMutableArray from Modal View Controller to Parent View

两盒软妹~` 提交于 2019-12-25 14:23:43
问题 I'm struggling to pass a NSMutable array from a Modal View controller back to the view controller I came from. This is my current method: FirstViewController.h #import "SecondViewController.h" @property (strong, nonatomic) IBOutlet NSMutableArray *passedRecipientsArray; FirstViewController.m @synthesize passedRecipientsArray = _passedRecipientsArray; - (void)viewDidAppear:(BOOL)animated { NSLog(@"passedRecipientsArray: %@", self.passedRecipientsArray); } - (void)prepareForSegue:

Objective C - Correct way to empty and reload UITableViewController with NSMutableArray

北城余情 提交于 2019-12-25 08:16:03
问题 I have a UITableViewController which uses a NSMutableArray for it's datasource. The array is initially populated in the viewDidLoad method by calling a web service to retrieve the data and populate the NSMutableArray. The user then has the option to enter a search term (in a UISearchBar) and press Search to rerun the web service and repopulate the table list. At this point I need to empty the array and repopulate the table from the results of the web service. My question is what is the

How to convert NSString intoNSArray?

眉间皱痕 提交于 2019-12-25 07:34:43
问题 I have an NSString which is a mathematical expression. I have operators (+,-,*,/) and operands (digits from 0 to 9,integers,decimals etc) . I want to convert this NSString into NSArray . For example if my NSString is "7.9999-1.234*-9.21". I want NSArray having elements 7.9999,-,1.234,*,-,9.21 in the same order. How can I accomplish this? I have tried a code. It dosent work in all scenarios though. Here It is: code: NSString *str=@"7.9999-1.234*-9.21"; NSMutableArray *marray=[[NSMutableArray

Baffled by NSMutableArray sortUsingDescriptors: exception

时光怂恿深爱的人放手 提交于 2019-12-25 07:25:09
问题 The following method: - (NSMutableArray*) timeSortedBegins { NSMutableArray* begins = [self.spans valueForKey: @"begin"]; NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey: @"cycleOffsetObject" ascending: YES]; [begins sortUsingDescriptors: @[sort]]; return begins; } throws this runtime exception: 2014-03-21 14:41:32.482 myValve[1741:60b] -[__NSArrayI sortUsingDescriptors:]: unrecognized selector sent to instance 0x16d7bc20 2014-03-21 14:41:32.484 myValve[1741:60b] ***

Get the correct index of dictionary

让人想犯罪 __ 提交于 2019-12-25 04:55:16
问题 NSMutableArray *tmpMutArr = [NSMutableArray arrayWithArray:allObjectsArray]; NSLog(@"The content of array is%@",tmpMutArr); int index; for (int i=0;i<[tmpMutArr count];i++) { if([[tmpMutArr objectAtIndex:i] isKindOfClass:[NSDictionary class]]) { NSMutableDictionary *tempDict = [tmpMutArr objectAtIndex:i]; if([[tempDict valueForKey:@"Name"] isEqualToString:[NSString stringWithFormat:@"%@", nameString]]) { index = i; } } } [tmpMutArr replaceObjectAtIndex:index withObject:[NSDictionary

Need to loop through an NSMutableArray that is stored inside an array in Parse.com database

余生颓废 提交于 2019-12-25 04:25:08
问题 I have an NSMutableArray object that contains NSString objects. The mutable array object is called _usersToAddToFriendsList . When I am done adding NSString objects to it, I run the following code for Parse.com: [PFUser currentUser]; PFQuery *query = [PFQuery queryWithClassName:@"_User"]; [query whereKey:@"username" equalTo:_userSubmittedUsername]; [query getObjectInBackgroundWithId:_objectId block:^(PFObject *object, NSError *error) { object[@"friends"] = _usersToAddToFriendsList; [object