nsarray

Is there a way to duplicate the number of NSDictionaries in an array?

只谈情不闲聊 提交于 2019-12-12 06:07:13
问题 I currently have this array of NSDictionary s in my table view, but I need to duplicate the number of dictionaries in the array as the table view scrolls down. Is there a way to achieve this, and also specify or know what the dictionary names will be? NSMutableDictionary *d0 = [[NSMutableDictionary alloc] init]; NSMutableDictionary *d1 = [[NSMutableDictionary alloc] init]; NSMutableDictionary *d2 = [[NSMutableDictionary alloc] init]; NSMutableDictionary *d3 = [[NSMutableDictionary alloc] init

how to compare 2 NSMutableArray and get different number of value

只愿长相守 提交于 2019-12-12 05:29:41
问题 I want compare 2 NSMutableArray values and check which indexPath is different and store this numbers of index in one array. for example I have these NSMutableArray : NSMutableArray *a = [[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6", nil]; NSMutableArray *b = [[NSMutableArray alloc]initWithObjects:@"11",@"2",@"5",@"3",@"53",@"6", nil]; and I want to compare these two NSMutableArray index to index (compare value to value) and tell me that which index of array in these

NSMutableArray always empty?

天涯浪子 提交于 2019-12-12 05:29:18
问题 Still have some difficulties to understand Obj-C's gestion of memory and some of its concepts. So my main class contains a NSMutableArray containing some characters and their list of weapons. It's like this : In Main class.h @property (nonatomic, retain) NSMutableArray *players; In Main class.m's init for(int i = 0 ; i < 30 ; i++) { [players addObject:[[PlayerInGame alloc] init:[self.tabPlayers objectAtIndex:i] :[self.tabWeapons:objectAtIndex:i]]]; } PlayerInGame.h @property (nonatomic,

Write and read file with list NSDictonary swift

吃可爱长大的小学妹 提交于 2019-12-12 05:14:12
问题 I have a list of NSDictionary, and i want to save it in a file. I can save it in text file but i can't read it to [NSDictionary] var text : [NSDictionary] = [] save file let json = JSONSerializer.toJson(text) try json.write(to: path, atomically: false, encoding: String.Encoding.utf8) This is my list NSDictionary [{ change = true; name = data1; },{ change = true; name = data2; }] 回答1: do { let text2 = try NSString(contentsOfURL: path, encoding: NSUTF8StringEncoding) // path give your file path

Get sectionIndex titles based on contact name

核能气质少年 提交于 2019-12-12 04:58:18
问题 In my app I have a db with 50k+ contacts. To display them on list view, I need to calculate the index section titles to display them on the right side. However my logic is taking time around 3-6 seconds to prepare the datasource. -(NSArray *)getSectionTitleBasedOn:(NSString*)sortBy{ for (RealmContact *contact in contactSource){ if (contact.firstName.length>0) { if ([sortBy isEqualToString:@"FirstName"]) { NSString *firName= [contact.firstName stringByReplacingOccurrencesOfString:@" "

Find the largest number from NSArray that is smaller than the given number

风格不统一 提交于 2019-12-12 04:53:29
问题 Suppose I have a sorted array of integers int[], and I want to search the closest smaller value to some input number. for example if the array contains 1 , 23 , 57 , 59 , 120 and the input is 109 , the output should be 59 . I have tried this but it is not working out as needed. NSTimeInterval currentTime = self.player.currentTime; NSInteger playerTime=currentTime; NSUInteger index = [_timesArray indexOfObject:@(playerTime) inSortedRange:NSMakeRange(0, _timesArray.count-1) options

Supposedly separate NSArray being contaminated by editing a copy

爱⌒轻易说出口 提交于 2019-12-12 04:49:37
问题 I have a TableView with some TextFields in. The values of said TextFields are linked to certain positions in a 2D Array (NSArray of NSMutableArrays). An initial clean array is defined as so: self.cleanEditContents = @[ [@[@-1,@-1] mutableCopy], [@[@0,@80] mutableCopy], [@[@0,@500] mutableCopy], [@[@-1,@-1] mutableCopy], [@[@-1,@-1] mutableCopy], [@[@-1,@-1] mutableCopy], [@[@-1,@-1] mutableCopy], [@[@-1,@-1] mutableCopy], [@[@-1,@-1] mutableCopy], [@[@-1,@-1] mutableCopy], [@[@-1,@-1]

Populating an Array from Core Data in Xcode

 ̄綄美尐妖づ 提交于 2019-12-12 04:45:53
问题 I am trying to populate an NSArray with a collection of data I get from CoreData. But my array doesnt seem to be populating with the data. I have the following code to retrieve the data: NSManagedObjectContext *managedObjectContext = [self managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"WeightLog"]; self.contactarray = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy]; And I am using the following for loop to

How to display an NSArray in a UILabel and use timer

好久不见. 提交于 2019-12-12 04:44:21
问题 I'm trying to display an array of numbers in a UILabel using a timer,and show them in the order set in the array, but I only receive the Title in the format and then a SIGABRT ! any suggestions...Thanks Part of the code with problems! -(IBAction) rotate3 { NSString *number = [dayArray initWithArray:(NSArray *)dayArray]; NSArray *array = [[NSArray alloc] initWithObjects: @"0", @"1", @"2", @"3", @"4", @"5" ,@"6", @"7", @"8",@"9",@"10",@"11",@"12",@"13", @"14", @"15", @"16", @"17", @"18", @"19"

NSArray returning NULL value even though right number of objects is counted and returned

一世执手 提交于 2019-12-12 04:25:25
问题 I have created a NSArray that contains images objects. Based on the swipe direction recognized by UISwipeGestureRecognizerDirection the index is incremented up or down so the right image could be selected. The problem I have is that my NSArray is returning a NULL value instead of the image object. Therefore the UIImageView (named imageView) displays nothing. I am printing an NSLog statement in order to see what is really happening - example below: ... [2307:60b] Swiped and the index is: 1,