nsarray

Display edited NSString in order

霸气de小男生 提交于 2020-01-15 12:13:43
问题 I have been working on this for a few days with help from this great community. I have a NSArray that I need to edit NSStrings within. I have managed to detect a marker in the string and make it bold. However now I am trying to display the strings in the order that they are within the NSArray whilst maintaining the Bold that was added to the specific strings. I can display the individual Bold String ' string ' but I need it to be in order that it is within the array. I know of

Delete Specific Items from NSMutableArray

北战南征 提交于 2020-01-15 09:15:19
问题 I'm trying to perform the relatively simple task of deleting the items in an NSMutableArray that fit a certain criteria. In this particular case, I'd like to delete the items where all of the following are true: city: Seattle state: WA timestamp: more than 60 seconds old An NSLog of my array looks like this: array = ( { city = "Seattle"; state = "WA"; timestamp = 1432844384; }, { city = "Dallas"; state ="TX"; timestamp = 1432844415; }, { city = "Seattle"; state = "WA"; timestamp = 1432845329;

Getting unique numbers from two arrays

时光毁灭记忆、已成空白 提交于 2020-01-15 05:26:09
问题 If I have a couple of NSArrays filled with ints , or NSNumbers , like so: A: { 12, 23, 45, 56, 67, 78, 99, 234 } B: { 12, 56, 78, 99, 454, 512 } How do I output an array with numbers that are in A but not in B, like { 23, 45, 67, 234 } 回答1: What you are tying to do is purely a set operation. So you can use NSSet here. You should do minusSet: to get the result you want. NSMutableSet *resultSet = [NSMutableSet setWithArray:A]; NSSet *setB = [NSSet setWithArray:B]; // This is what you need!

Complex NSDictionary. Taken objectsforkeys and sorting them as NSArray or separate variables?

巧了我就是萌 提交于 2020-01-15 04:32:04
问题 I have an NSDictionary that was converted from XML that is really confusing me. If you could take a look and let me know the best method of getting the objects for the key class_id, I would really appreciate it. { response= { "@status" = ok; rosters = { "@page" = 1; "@page_count" = 1; "@records_per_page" = 50; "@total_record_count" = 8; roster = ( { "@class_id" = 0001; "@role" = 0; "@user_id" = 12345; class= { "@active" = false; "@name" = NAME; } } { "@class_id" = 0002; "@role" = 0; "@user_id

Filter NSArray with NSDictionary (nested level of object) using NSPredicate ANY and IN?

北慕城南 提交于 2020-01-14 06:09:17
问题 I have one main array named originalListArray with multiple objects.Here is the example of object. Example.json I want to find that number of objects from the originalListArray , who have amenity_id matched with my filter data. I have do this, create one predicate usign ANY not self becuase NSArray with NSDictionary and in that Dictionary object may have NSArray data. This is working fine. NSPredicate *predicate=[NSPredicate predicateWithFormat:@"ANY amenities.amenity_id =='1')"]; This is not

Memory leak with a lot of big images in iPad

时间秒杀一切 提交于 2020-01-14 03:26:09
问题 I'm trying to store UIImage datas in NSArray , actually 60 images, each with size of 300kb. Then, I'm trying to animate that images in UIImageView . My code: NSMutableArray *arr = [[NSMutableArray alloc] init]; for (int i=0; i<61; ++i) { [arr addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%i.png", i]]]; } img.animationImages = arr; img.animationDuration = 1.5; img.contentMode = UIViewContentModeBottomLeft; [img startAnimating]; When I test it in iPad Simulator 4.3, it works fine.

Slice NSArray from end of array

社会主义新天地 提交于 2020-01-12 18:56:37
问题 What is the best way to "slice" an NSArray from the end, rather than the beginning, of the array (for example, finding the subarray containing the last few elements of a NSArray of unknown length)? In Python, you can use negative indices to accomplish this, e.g.: new_list = old_list[-5:-3] What's the most natural way to do this in Objective-C? 回答1: There's nothing to match Python's nice syntax for this, but you could do: NSUInteger count = [myArray count]; NSArray * slice = [myArray

Filter array of dictionaries by NSString

做~自己de王妃 提交于 2020-01-12 10:28:54
问题 while implementing search functionality I need to filter array of dictionaries. I am using auto complete textfield method for search bar and am storing it into string. I can able to parse the array,But facing with below json [{"CertProfID":"4","Name":"Dodge","Location":"loc4","City":"city4","State":"state4","Zip":"zip5","Website":"http:\/\/cnn.com","Phone":"phone4","Email":"email4"}, {"CertProfID":"5","Name":"cat","Location":"loc5","City":"city5","State":"State5","Zip":"zip5","Website":"web5"

iOS: Best Way to do This w/o Calling Method 32 Times?

主宰稳场 提交于 2020-01-11 14:07:59
问题 I'm currently retrieving the Top 100 Scores for one of my leaderboards the following way: - (void) retrieveTop100Scores { __block int totalScore = 0; GKLeaderboard *myLB = [[GKLeaderboard alloc] init]; myLB.identifier = [Team currentTeam]; myLB.timeScope = GKLeaderboardTimeScopeAllTime; myLB.playerScope = GKLeaderboardPlayerScopeGlobal; myLB.range = NSMakeRange(1, 100); [myLB loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) { if (error != nil) { NSLog(@"%@", [error

Can't append value to my NSArray variable

偶尔善良 提交于 2020-01-11 14:07:12
问题 I have a NSArray and i need to append some values but array.append doesn't seems to works on a NSArray. What can i use to append something on a NSArray like a normal array 回答1: You can not add or append element in NSArray as NSArray is immutable.For this you need to take NSMutableArray 来源: https://stackoverflow.com/questions/26948610/cant-append-value-to-my-nsarray-variable