nsarray

add a NSArray to NSMutableArray

本小妞迷上赌 提交于 2020-01-07 08:21:25
问题 i want to add a NSArray to my NSMutable ( init in the appdelegate ) this is my code, the method is call each time a button (male, female, couple) is pressed so an NSArray has to be add to the MutableArray but i don't know i tried stuff but doesnt work. : - (void) sexChoosen:(NSString *) sexe { NSError *err; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Boxes" inManagedObjectContext:context]; [request setEntity

What is the most efficient way to generate a sequence of NSNumbers?

佐手、 提交于 2020-01-06 20:06:45
问题 It's a fairly simple builtin in python for example: x = range(0,100) How can I accomplish the same feat using objective-c methods? Surely there is something better than a NSMutableArray and a for-loop: NSMutableArray *x = [NSMutableArray arrayWithCapacity:100]; for(int n=0; n<100; n++) { [x addObject:[NSNumber numberWithInt:n]]; } Yes, I am aware that doing this is most likely not what I actually want to do (ex: xrange in python), but humor my curiosity please. =) Clarification: I would like

Array displaying repeated object in table view cell

☆樱花仙子☆ 提交于 2020-01-06 19:46:06
问题 I am having a NSArray of size 11 as it formed below. labels = [NSMutableArray arrayWithObjects:@"DIN #",@"Brand Name",@"Full Name", @"Strength", @"Medication Type", @"Presciption ID", @"Next Dosage", @"Required Dosage", @"ada", @"dasdada", @"dasdasad", nil]; but when i am displaying this array in tableview cell Using this code. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {static NSString *CellIdentifier = @"Cell"; UITableViewCell

Check for duplicate NSStrings on a NSMutableArray

眉间皱痕 提交于 2020-01-06 14:27:12
问题 I got a NSMutableArray which I want to add strings to. I need to check if that string already exists on the array before adding ths string to it. Does anyway know a good way to do it? Thanks! 回答1: If order doesn't matter, the simplest way would be to switch to using an NSMutableSet. Sets are unordered and NSSets and NSMutableSets can contain each object only once. Only a counted set (NSCountedSet) can contain the same object multiple times. If order does matter, continue using NSMutableArray,

iPhone : JSON message not creating correctly

假装没事ソ 提交于 2020-01-06 05:09:25
问题 I used the following code : [dict setObject:[NSString stringWithFormat:@"%d",1] forKey:@"res_id"]; //[dict setObject:categoryId forKey:@"category"]; NSArray * values = [cartDict allValues]; NSString *request1 = [dict JSONRepresentation]; NSLog(request1); NSDictionary *req = [NSDictionary dictionaryWithObject:dict forKey:@""]; //convert object to data NSData *jsonData = [NSData dataWithBytes:[request1 UTF8String] length:[request1 length]]; //print out the data contents NSString *json1 = [

iOS - Add NSDictinary key values into an NSArray sequencialy

旧街凉风 提交于 2020-01-05 21:12:21
问题 I have a NSDictionary and a NSArray : self.dataDic = [[[NSDictionary alloc] init] autorelease]; self.dataDicKey = [[[NSArray alloc] init] autorelease]; These are the key and value of my NSDictionary : self.dataDic = @{@"Ring Cloud" :@[@"Contact Cloud", @"Image Cloud", @"Data Cloud"], @"Ring Tools" :@[@"Sticker Market", @"Live Poll", @"Mail"], @"Ring Apps" :@[@"Studio", @"Player"]}; Now what I want is to insert all the key value of my self.dataDic into self.dataDicKey sequentially. That means

iOS - Add NSDictinary key values into an NSArray sequencialy

我是研究僧i 提交于 2020-01-05 21:09:32
问题 I have a NSDictionary and a NSArray : self.dataDic = [[[NSDictionary alloc] init] autorelease]; self.dataDicKey = [[[NSArray alloc] init] autorelease]; These are the key and value of my NSDictionary : self.dataDic = @{@"Ring Cloud" :@[@"Contact Cloud", @"Image Cloud", @"Data Cloud"], @"Ring Tools" :@[@"Sticker Market", @"Live Poll", @"Mail"], @"Ring Apps" :@[@"Studio", @"Player"]}; Now what I want is to insert all the key value of my self.dataDic into self.dataDicKey sequentially. That means

UITableView crashes when number of rows >1

独自空忆成欢 提交于 2020-01-05 12:09:28
问题 I have a uitableview that crashes when row is greater than one. It makes no sense at all since their are two objects in the array. It works perfectly for object one, but not two. Check it out: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"rigth not %i", [pro.matches count]); return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell";

how to add JSON data to an NSArray

旧城冷巷雨未停 提交于 2020-01-05 10:10:33
问题 I have json data as below. [ {"id":"2","imagePath":"image002.jpg","enDesc":"Nice Image 2"}, {"id":"1","imagePath":"image001.jpg","enDesc":"Nice Image 1"} ] I am assigning this to variable named NSArray *news . Now I have three different array as below. NSArray *idArray; NSArray *pathArray; NSArray *descArray; I want to assign data of news to these arrays so that finally I should have as below. NSArray *idArray = @["2","1"]; NSArray *pathArray = @["image002.jpg","image001.jpg"]; NSArray

how to add JSON data to an NSArray

北战南征 提交于 2020-01-05 10:10:02
问题 I have json data as below. [ {"id":"2","imagePath":"image002.jpg","enDesc":"Nice Image 2"}, {"id":"1","imagePath":"image001.jpg","enDesc":"Nice Image 1"} ] I am assigning this to variable named NSArray *news . Now I have three different array as below. NSArray *idArray; NSArray *pathArray; NSArray *descArray; I want to assign data of news to these arrays so that finally I should have as below. NSArray *idArray = @["2","1"]; NSArray *pathArray = @["image002.jpg","image001.jpg"]; NSArray