nsmutablearray

Delete from uitableview + write to plist not working

佐手、 提交于 2019-12-02 10:31:37
i want to delete from uitableview and make it write to my plist. i'm pretty new to this objective-c iOS coding, so forgive me for mistakes Right now with my code it crashed with this : Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (11) must be equal to the number of rows contained in that section before the update (11), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus

Add objects to NSMutable array with grouping

拜拜、爱过 提交于 2019-12-02 09:14:27
I want my NSArray sampleData to receive actual data from parse.com database assuming like this: self.sampleData = @[ @{ @"date": @"12/5/2014", @"group": @[ @{ @"text": @"post1", @"location": @"x,y" }, @{ @"text": @"post2", @"location": @"x,y" }, @{ @"text": @"post3", @"location": @"x,y" }, @{ @"text": @"post4", @"location": @"x,y" }, @{ @"text": @"post5", @"location": @"x,y" } ] }, @{ @"date": @"12/3/2014", @"group": @[ @{ @"text": @"post6", @"location": @"x,y" }, @{ @"text": @"post7", @"location": @"x,y" }, @{ @"text": @"post8", @"location": @"x,y" }, @{ @"text": @"post9", @"location": @"x,y"

Access NSMutableArray from a different class

余生长醉 提交于 2019-12-02 08:47:13
I have a class where a NSMutableArray object is formed, as so: navBarColour = [[NSMutableArray alloc] initWithObjects:colourOfNavBar, nil]; I then have another class, which has the first class added to it properly, but it won't let me access the NSMutableArray from the first class. This line of code: NSLog(@"%@", [HandlingPalettes.navBarColour objectAtIndex:0]); Returns: expected ':' before '.' token But: NSLog(@"%@", [navBarColour objectAtIndex:0]); would work in the original class. What am i doing wrong here? The dot notation is used differently in objective c that from c++ or java. In

Deleting objects within a for loop from a NSMutableArray

天涯浪子 提交于 2019-12-02 08:44:34
问题 I am working with a UITableView and for each of the objects in the array that is the datasource for the UITableView , I am deleting them if they meet a certain if statement. My problem is that it only deletes every-other object from the array. Code: UIImage *isCkDone = [UIImage imageNamed:@"UITableViewCellCheckmarkDone"]; int c = (tasks.count); for (int i=0;i<c;++i) { NSIndexPath *tmpPath = [NSIndexPath indexPathForItem:i inSection:0]; UITableViewCell * cell = [taskManager

proper memory handling for an NSMutableArray assigned to property?

柔情痞子 提交于 2019-12-02 08:15:12
I have a property declared like this: @property (nonatomic, retain) NSMutableArray *pricingLevels; And I assign it like this: self.pricingLevels = [[[NSMutableArray alloc] init]; in my dealloc I have this: self.pricinglevels=nil; When I analyze my code with xCode it says I have a memory leak here: self.pricingLevels = [[[NSMutableArray alloc] init]; Should I be using an autolrelease on this because the self.pricinglevels holds a reference to the array also? self.pricingLevels is a property declared as retained which means every time you set it thru property assignment (the dot-syntax OR the

addObject: to array not working (array still nil)

北慕城南 提交于 2019-12-02 08:00:28
This app is a table view with a tab bar controller. I am logging the count of the array: arrayOfFavourites and even though i add an object is continues to have a nil value, my relating code, all objects shown are allocated and initialized in the code (previous or present) some are instances and some are properties: ListViewController.m: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"TOUCHED CELL!"); // Push the web view controller onto the navigation stack - this implicitly // creates the web view controller's view the first time through [

How to populate my tableview with a mutablearray from json

不打扰是莪最后的温柔 提交于 2019-12-02 07:59:10
So I'm fetching data from a url which is in a json format. I'm trying to display the data in my tableview but, even though it feels simple, I can't figure out how to do it. class CompanyModel { func getJSON() { let companyArray: NSMutableArray = NSMutableArray() let requestURL: NSURL = NSURL(string: "http://localhost/Companies/JSON.php")! let urlRequest: NSMutableURLRequest = NSMutableURLRequest(URL: requestURL) let session = NSURLSession.sharedSession() let task = session.dataTaskWithRequest(urlRequest) { (data, response, error) -> Void in let httpResponse = response as! NSHTTPURLResponse let

App Crashing: Mutating method sent to immutable object

天大地大妈咪最大 提交于 2019-12-02 07:31:34
I am trying to add an object to an NSMutableArray . Initially I assign some response data to the array, and can display it in a table view. After loading more data, it seems to be crashing when trying to add the new information to my original array. I am using AFNetworking for this: [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if(!_myArray){ _myArray = [responseObject objectForKey:@"data"]; } else{ [_myArray addObject:[responseObject objectForKey:@"data"]]; } [self.tableView reloadData]; } The error I am getting is as follows ***

Getting Top 10 Highest Numbers From Array?

感情迁移 提交于 2019-12-02 07:17:18
I am having a bit of a issue. I have an NSMutableDictionary with 10 NSMutableArrays in it. Each array has somewhere between 0-10 numbers which could each be any integer, e.g. 12 or 103. What I need to do is get the top 10 highest numbers from across each of the arrays. The trouble is, I need to keep a reference of the array it came from in the dictionary (the key) and the index position of the number from the array it came form. Easiest way, is to sort the array in Descending order, and then grab the first 10 indexes Or if they are inside dictionaries, iterate the dictionary allValues , grab

NSMutableArray addObjects - unrecognized-selector

荒凉一梦 提交于 2019-12-02 05:38:27
This is how I initialize my NSMutablearray. I copy the content of cityList into cityArray. Both are NSMutableArray. FYI, I declared the'cityArray' using extern. cityArray = [[NSMutableArray alloc] init]; [cityArray addObjectsFromArray:cityList]; Then, in other method in another class, I tried to to add one more object into 'cityArray' This is how I do it. But it keep crashing when it run this line of code. NSString *allCities = @"All Cities"; [[cityArray valueForKey:@"cityName"] addObject:allCities]; This is from the console '[__NSArrayI addObject:]: unrecognized selector sent to instance