nsmutablearray

Access multi dimension NSMutableArray of NSMutableArrays using UITableView indexPath

若如初见. 提交于 2019-12-11 10:07:55
问题 I have a UITableView with a dynamic amount of sections and rows, I am wanting to use a custom cell.accessoryView which I have managed to create using the following code. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [stackRotationController pop]; cell = (TreeCell *)[cuttingTableView cellForRowAtIndexPath:indexPath]; UIImageView *checkmark = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"findbitting@2x.png"]]; NSNumber *newState; if ([

How can I pass a “MutableArray with full of Objects” to another class by using NSUserDefaults?

风流意气都作罢 提交于 2019-12-11 09:39:42
问题 How can I pass a " MutableArray with full of Objects" to another class by using NSUserDefaults ? I know how to pass " MutableArray "s but this does not work! So; I have a MutableArray; ' myCityObjects ', and I populate it with objects; ' cities ' In each ' cities ' object there are properties like cityName , cityLocation etc... [myCityObjects addObject:cities]; Now, what I want to do is to pass this MutableArray (filled with objects) to another class by using ' NSUserDefaults '; [

How do I order my images in my photosNSMutable array by “created_time” and get my collection view to display them accordingly?

别说谁变了你拦得住时间么 提交于 2019-12-11 09:38:31
问题 // // ViewController.swift // Fashun // // Created by Alex Macleod on 20/10/14. // Copyright (c) 2014 Alex Macleod. All rights reserved. // import UIKit class ViewController: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { var collectionView: UICollectionView? var instanceOfCustomObject: CustomObject = CustomObject() var accessToken: NSString! = "14128167.52d0add.2fbff9669d9141099597cbb8d67764a4" var userDefaults: NSUserDefaults! let colorWheel = ColorWheel(

Exc bad access after populating NSMutableArray with custom class extending CLPlacemark

耗尽温柔 提交于 2019-12-11 09:15:58
问题 I have a PlaceAnnotation class that I fill into an NSMutableArray. In viewDidLoad, i initiate ihatethis _ihatethis = [[NSMutableArray alloc]init]; I use a MKLocalSearchCompletionHandler to search. And handle the mapitems like this: for (MKMapItem *mapItem in [response mapItems]){ PlaceAnnotation *place = [[PlaceAnnotation alloc] init]; [place assignTitle:[[mapItem placemark] name]; [_ihatethis addObject:place]; } [_ihatethis removeObjectAtIndex:2]; /*BAD ACCESS HERE*/ [_tableView reloadData];

Get Files Inside a folder in Document directory in iPhone

邮差的信 提交于 2019-12-11 08:48:07
问题 I am new to iPhone, I made an app in which, i am downloading a book and storing it in a folder called book1Folder which is inside Document directory . now i wants name of all books in my array, there are 2 books inside a book1Folder but when i write this code it shows me array count is 3. Here is my code snippet, -(void)viewWillAppear:(BOOL)animated{ NSString *files; NSString *Dir=[self applicationDocumentsDirectory]; Dir=[Dir stringByAppendingPathComponent:@"book1Folder"];

How to add UIImages to an NSMutableArray, and change the images later?

偶尔善良 提交于 2019-12-11 07:42:13
问题 I am making a simple game that requires that I draw multiple UIImages in many different places. My problem here is that I need to add the UIImages to an NSMutableArray, and access them later. Using NSStrings to represent the images (such as for paths) will not work here, so I need to know how to change the images for every UIImage in the array. My code is as follows (at least, for accessing the NSMutableArray). The NSMutableArray is declared in my .h file, and is initialized in a different

What will be the numberOfRowsInSection return type for uitableview when XML data is retrieved?

我是研究僧i 提交于 2019-12-11 07:27:15
问题 I have a NSMutableArray named as records and a NSArray . Now I am retrieving an XML attribute and its value, using TBXML parser and inserting the attribute value in the NSArray . This NSArray is an object of records . What will be the numerberOfRowsInSection when I want to display the value of XML data in tableview cell? This is my data retrieving procedure.... [records addObject:[NSArray arrayWithObjects: [TBXML textForElement:id], [TBXML textForElement:productNumber], [TBXML textForElement

How to sort an NSMutableArray containing numbers as strings, in descending order

本小妞迷上赌 提交于 2019-12-11 07:11:15
问题 I was sorting an NSMutableArray containing numbers as strings, in descending order . My array is in the same form as below: {273,0,0,0,0,0,48,48,59,254} I was looking for sorting it in descending order. That is expected result is: {273,254,59,48,48,0,0,0,0,0} I tried: [[[myArray sortedArrayUsingSelector:@selector(compare:)] reverseObjectEnumerator] allObjects]; The result was weird. It was: {59,48,48,273,254,0,0,0,0,0} -- zeros are not getting sorted, and not proper sort Then I tried:

NSMutableArray removeAllObjects crash

北城以北 提交于 2019-12-11 07:00:57
问题 Car class -------------- price color crash code is: NSMutableArray *list = [[NSMutableArray alloc] init]; Car *car = [[Car alloc] init]; car.price = 10; car.color = 1; [list addObject:car]; // some code [list removeAllObjects]; // Crash here why crash, how can i resolve it. app exit with nothing output 回答1: I dont know what you have in the "someCode" section in your segment. You first comment out that code and check if the app crashes. If still it crashes then only consider what I have given

NSUserdefaults works on Simulator but not on Device

人盡茶涼 提交于 2019-12-11 06:45:11
问题 I would like to save an NSArray to NSUSerDefaults . If I do it on Simulator everything works, if I do it on Device, it doesnt work. NSArray *Test1 = [Daten copy]; NSArray *Test2 = [Kosten copy]; [prefs setObject:Test1 forKey:@"Daten"]; [prefs setObject:Test2 forKey:@"Kosten"]; I am using the above code. prefs is a normal NSUserDefaults , like NSUserDefaults *prefs = [NSUserDefaults standartUserDefaults]; ... Daten & Kosten are Mutable Arrays, to work with. Everything works on simulator, but