nsmutablearray

how to sort the time in a NSMutableArray in ios

拥有回忆 提交于 2019-12-06 12:19:32
i'm having a set of Dictionaries in a NSMutableArray. now i want to sort ascending & Descending order by time here is my Array value. ( { StartTime = "09:00 AM"; TravelsName = "ABC Travels"; }, { StartTime = "07:30 AM"; TravelsName = "XYZ Travels "; }, { StartTime = "06:45 PM"; TravelsName = "GSP Travels"; }, { StartTime = "05:00 PM"; TravelsName = "Madura Travels"; }, { StartTime = "12:45 AM"; TravelsName = "MJT Travels"; }, { StartTime = "12:45 PM"; TravelsName = "OPR Travels"; }, { StartTime = "01:00 AM"; TravelsName = "VMS Travels"; } ) Please help me i had sorted the set of NSDate inside

Convert NSString to NSArray [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 11:09:32
This question already has answers here : Comma-separated string to NSArray in Objective-C (2 answers) Closed 6 years ago . I have one string as follows: NSString *str = @"abcd,efgh"; Now I want to convert this string into NSMutableArray like NSMutableArray *arr = {abcd,efgh}; then how can I do this? any help would be appreciated. NSArray *arr = [@"abcd,efgh" componentsSeparatedByString:@","]; should do the job. 来源: https://stackoverflow.com/questions/15271450/convert-nsstring-to-nsarray

How to group an NSMutableArray and show in UITableView?

旧巷老猫 提交于 2019-12-06 10:00:41
I get json from server and add them in NSMutableArray like this: { "title": "title60", "summary": "summary60", "datetime": "2013.02.03", } { "id": 58, "title": "title59", "summary": "summary59", "datetime": "2013.02.03", }, { "id": 57, "title": "title58", "summary": "summary58", "datetime": "2013.02.04", }, { "id": 56, "title": "title57", "summary": "summary57", "datetime": "2013.02.04", }, { "id": 55, "title": "title56", "summary": "summary56", "datetime": "2013.02.05", } How can I use the NSMutableArray group by "datetime" and show in uitableview? You can roll your own data structures for

NSMutableArray Difficulty

梦想与她 提交于 2019-12-06 09:43:21
问题 If you wanna see the code Im having problem with, here is the link: Code My question is connected with my past question. I'm really having problem with my NSMutableArray , I'm currently using iCarousel for my slotMachine object(slot1 and slot2). My app works this way: From PhotoViewController I made a view that has thumbnail images, then assign its frame with button. So if 1 image was pressed, it will save that integer via NSUserDefaults . Then I will retrieve it in my carouselViewController

Faster sort of NSMutableArray of MPMediaItems? Code Review

早过忘川 提交于 2019-12-06 09:39:03
问题 I'm a couple weeks into iOS programming, and have lots to learn. I've got a sort of an NSMutableArray containing MPMediaItems working, but it's about 10 seconds slow with a sort of 1200 items and I'm looking for an approach that would be faster. My ultimate goal is to have an array of MPMediaItemCollection items, each representing an album. I can't get this from an MPMediaQuery (as far as I know) because I need to get the songs from a playlist. So I'm sorting the songs I get from a specific

how to check if NSMutableArray element is NSNull or AnyObject

霸气de小男生 提交于 2019-12-06 08:24:24
I have a PersonsArray: NSMutableArray = [NSNull, NSNull, NSNUll, NSNull, NSNull, NSNUll, NSNull] . I needed seven slots that I then can fill with an Entity CoreData entry as AnyObject. I need to do a for in loop on this NSMutableArray... If the index slot is NSNull I want to pass to next index slot, if index slot is filled with my Object I want to execute code on this Object. example PersonsArray: NSMutableArray = [ NSNull, NSNull, NSNull, "<iswift.Person: 0x7f93d95d6ce0> (entity: Person; id: 0xd000000000080000 <x-coredata://8DD0B78C-C624-4808-9231-1CB419EF8B50/Person/p2> ; data: {\n image =

shuffle NSMutableArray without repetition and showing in a UIButton

旧时模样 提交于 2019-12-06 08:18:29
In my view, i have 12 buttons,and a array contains 6 names , i want to print the array names in UIButton title. Here's my code: texts = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",nil]; UIButton *button; NSString *name; NSUInteger count = [texts count]; int i=0; for(UIView *view in self.view.subviews) { if([view isKindOfClass:[UIButton class]]) { button= (UIButton *)view; if(button.tag >= 1||button.tag <= 20) { int value = rand() % ([texts count] -1) ; int myTag= i+1; button = [self.view viewWithTag:myTag]; name=[NSString stringWithFormat:@"%@",[texts objectAtIndex

How to lazy load?

只愿长相守 提交于 2019-12-06 07:50:16
How do you lazy load a NSMutableArray in tableView:didSelectRowAtIndexPath: ? I am very new to Objective-C, XCode, and iOS programming, so any help is appreciated. Lazy load means 'loading on demand'. So you perform operation only when it is really necessary, and not beforehand. Say we have method: -(void) init { self = [super init]; mMyMemberArray = [self loadSomeDataToArray]; } -(void) tableView:didSelectRowAtIndexPath: { [someObject processData: mMyMemberArray]; } This is not lazy loading cause we've loaded data beforehand. But this: -(void) tableView:didSelectRowAtIndexPath: { someObject

Adding objects in Multidimensional NSMutableArray

梦想的初衷 提交于 2019-12-06 07:24:14
I'm quite confused on how to add objects in multidimensional arrays. Is initializing multidimensional arrays are the same with just a simple array? This is my initialization. testList = [[NSMutableArray alloc] init]; I need to do something like testList[i][j] = item; i tried [[[testList objectAtIndex:i]objectAtIndex:j] addObject:item]; but it doesn't seem to work :( Jakub You are add to much C to do this. This is important to know how to NSMutableArray works and how it's different compare to 2D arrays known from C/C++. In mutable array you could store another arrays. For example:

IOS(swift)-数据存储 · NSKeyedArchiver 归档

五迷三道 提交于 2019-12-06 07:00:28
需求: 有一个通讯列表,可以自行添加联系数据,但是重新开启后,添加的数据都会清空,我希望打开后,上一次的数据能保留。 这我们就必须用到数据持久化,这一次,我将用NSKeyedArchiver 归档 方式来做数据持久化,达到再次打开应用后,数据依然存在。 通讯录.png NSKeyedArchiver、NSKeyedUnarchiver ,主要用在ios数据存储上,数据从内存存储到闪存上,这个过程称为归档。Apple官方文档中,这些数据类型包括: NSData、NSString、NSNumber、NSDate、NSArray、NSDictionary。很显然,复杂数据例如UIImage,无法直接归档。但我们有一种变通的做法,先将UIImage对象转换为NSData,再对NSData进行归档。 一、创建一个数据模型(自定义类) import UIKitclass JKContactModel: NSObject,NSCoding{ var name:NSString! var phone:NSString! func encodeWithCoder(aCoder: NSCoder){ aCoder.encodeObject(self.name, forKey: "name") aCoder.encodeObject(self.phone, forKey: "phone") }