nsmutablearray

2D arrays using NSMutableArray

人盡茶涼 提交于 2019-12-17 07:11:00
问题 I need to create a mutable two-dimensional array in Objective-C. For example I have: NSMutableArray *sections; NSMutableArray *rows; Each item in sections consists of an array rows . rows is an array that contains objects. And I want to do something like this: [ sections[i] addObject: objectToAdd]; //I want to add a new row In order have something like this: section 0, rows: obj1, obj2, obj3 section 1, rows: obj4, obj5, obj6, obj 7... Is there a way to do that in Objective-C? 回答1: First, you

NSMutableArray addObject not affecting count?

天大地大妈咪最大 提交于 2019-12-16 20:07:28
问题 Can anyone tell me why logging [self.giftees count] keeps returning 0 even though I'm adding objects to it? header: #import <UIKit/UIKit.h> @interface Test2AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; NSMutableArray *giftees; } @property (nonatomic, retain) UIWindow *window; @property (nonatomic, retain) NSMutableArray *giftees; @end called from didFinishLaunchingWithOptions: - (void)bootstrapGiftees { NSArray *gifteeNames = [NSArray arrayWithObjects:@"Jesse",,nil]; for

NSMutableArray addObject not affecting count?

╄→гoц情女王★ 提交于 2019-12-16 20:06:05
问题 Can anyone tell me why logging [self.giftees count] keeps returning 0 even though I'm adding objects to it? header: #import <UIKit/UIKit.h> @interface Test2AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; NSMutableArray *giftees; } @property (nonatomic, retain) UIWindow *window; @property (nonatomic, retain) NSMutableArray *giftees; @end called from didFinishLaunchingWithOptions: - (void)bootstrapGiftees { NSArray *gifteeNames = [NSArray arrayWithObjects:@"Jesse",,nil]; for

Accessing Coordinates in Plist - iOS [closed]

。_饼干妹妹 提交于 2019-12-14 04:15:16
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . Instead of accessing specific latitude with hardcoded as shown in below NSString *path = [[NSBundle mainBundle] pathForResource: @"WellList" ofType:@"plist"]; NSMutableDictionary *root = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; NSString* latitude = [[[[[root objectForKey: @"Routes

Deleting in NSMutableArray

≯℡__Kan透↙ 提交于 2019-12-14 04:00:26
问题 I have an array here, example I have 4 images on each column, each responds to its default index: When an image is deleted for example index 1. as shown in the image below: The index becomes 0,1,2 : which I want to be is 0,2,3 (Which is the original array index): Could anyone help me on how to achieve this? my code for my array: self.myImages = [NSMutableArray array]; for(int i = 0; i <= 10; i++) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES

addObject replaces previous object in NSMutableArray

人走茶凉 提交于 2019-12-14 03:57:16
问题 I'm trying to add objects to a NSMutableArray through a for loop. But it seems whenever I add an object it replaces the old one so that I only have one object in the array at the time... Do you have any idea of what might be wrong? - (void)viewDidLoad { [super viewDidLoad]; LoginInfo *info = [[LoginInfo alloc] init]; info.startPost = @"0"; info.numberOfPosts = @"10"; info.postType = @"1"; getResults = [backendService getAllPosts:info]; for (NSInteger i = 0; i < [getResults count]; i++) { Post

How can one sort an NSMutableArray of NSMutableArrays containing NSStrings?

不想你离开。 提交于 2019-12-14 01:48:26
问题 Is there an easy way to sort an NSMutableArray of NSMutableArrays containing NSStrings? I am sure that there must be an easy method for doing this but I can't seem to find it. To Clarify I want to sort the first array alphabetically by the NSString at index 3 of the sub array. 回答1: Didn't see anyone actually answering this with other than "use this function, figure it out". So here is some actual code that you can use. Put this category at the end of your .h file (or anywhere and import the

Copy NSMutablearray to another

[亡魂溺海] 提交于 2019-12-14 00:24:15
问题 I am trying to copy NSMutableArray to another but it does not show me anything at the UITableView : NSMutableArray *objectsToAdd= [[NSMutableArray alloc] initWithObjects:@"one",@"two"]; NSMutableArray *myArray = [[NSMutableArray alloc] initWithObjects:objectsToAdd,nil]; NSMutableArray *list = [[NSMutableArray alloc] init]; [self.list addObjectsFromArray:myArray]; Nothing show up! What is wrong? It crashes my app because I do not have nil at my NSMutableArray how can I add nil to it? addobject

NSArray clears after 3 times view did load

只愿长相守 提交于 2019-12-13 22:17:35
问题 I have an NSArray that contains a couple of items. The NSArray is loaded into a uitableview from another class. when I back out of the detail view and re-enter (for the 3rd time), the NSArray is empty and the tableview is empty as well. What is happening? (I am using arc so I don't think it is a leak) - (void)viewDidLoad { myMatch = [[Match alloc] initWithId:1 OpponentId:13]; } - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString

Parse a Json Table to a NSMutableArray [duplicate]

与世无争的帅哥 提交于 2019-12-13 22:08:14
问题 This question already has an answer here : Parsing Json to get all the contents in one NSArray (1 answer) Closed 5 years ago . for the moment I fill in my array directly by a native objective-C code : Datas *pan1 = [[Datas alloc] initWithTitle:@"My array 1" title:@"Shakespeare's Book" location:@"London"]; Datas *pan2 = [[Datas alloc] initWithTitle:@"My array 2" title:@"Moliere's Book" location:@"London"]; NSMutableArray *datasListe = [NSMutableArray arrayWithObjects:pan1, pan2, nil]; But I