nsarray

iPhone sdk: how to delete duplicates in the NSArray

烂漫一生 提交于 2019-12-08 04:20:31
Hi My NSArray contains duplicates like this(i have to delete the duplicates) titles: Father's Day titles: Father's Day titles: Father's Day titles: Election Day titles: Election Day titles: Election Day titles: Easter titles: Easter titles: Earth Day titles: Earth Day titles: Earth Day titles: Cinco de Mayo titles: Cinco de Mayo titles: Cinco de Mayo titles: Christmas Eve titles: Christmas Eve titles: Christmas Eve titles: Christmas titles: Christmas titles: Christmas I have keep one name only and other duplicates are not wanted. how i have do this please guide me with bit clear explanation,

Arbitrary Attributes in Core Data

一个人想着一个人 提交于 2019-12-08 01:56:29
问题 In short, I want to associate arbitrary key/value pairs with the objects of a Core Data entity, on an iPad app. My current solution is to have a to-many relationship with another entity that represents a single pair. In my application, I have: Entry <--->> ExtraAttribute where ExtraAttribute has properties key and value , and the key is unique to the ExtraAttribute's Entry. Although the code to deal with this is slightly complicated, it is acceptable. The real problem comes with sorting . I

How to randomize an NSArray? [duplicate]

梦想与她 提交于 2019-12-08 01:48:55
问题 This question already has answers here : What's the Best Way to Shuffle an NSMutableArray? (12 answers) Closed 4 years ago . Let's say I have a NSArray with 50-100 objects inside. How can I put the array in a random order? 回答1: There are a lot of ways to do it, but most will involve simply generating random numbers. Perhaps you could use this technique using an NSMutableArray: Generate a random number between 0 and 49 (assuming 50 elements) Swap elements 0 and whatever number you generate

Sort NSArray of NSDictionaries using comparator

偶尔善良 提交于 2019-12-07 23:12:13
问题 I've been trying to sort an NSArray of NSDictionaries using a comparator, but I cannot seem to get the output I desire. The output I'm trying to achieve is that A-Z usernames should come first in the sorted array, then usernames that start with a digit should come second in the sorted array, and lastly usernames that start with an underscore should be last in the sorted array. Any help is truly appreciated! EDIT: It should be sorted so it looks consistent through the whole NSArray so that:

finding NSDate's in an NSArray that have a time of day after a given time (e.g. 8pm)?

百般思念 提交于 2019-12-07 19:52:53
问题 Is there a quick way in Objective-C of identifying NSDate's in an NSArray that have a time of day after a given time (e.g. 8pm)? I can't quite see anyway other than manually walking through each NSDate in the array and then using NSDateComponents to break out the hour/minute/second...Not even sure if there is a simple way to get the time from an NSDate in a fashion that represents a fraction of 24hours, as this might help a little. (e.g. 6pm would be 18/24 = 0.75 in this case) 回答1: There is

Does the removeAllObjects method of an NSArray or NSMutableArray release memory?

橙三吉。 提交于 2019-12-07 19:41:16
问题 I need to know if the removeAllObjects method of an NSArray or NSMutableArray releases memory. If my array has got 10000 elements. Can I use the [array removeAllObjects]; to release the memory and reload it with other elements? Or it leaks memory? Thanks EXAMPLE if the size of my NSMutable array is 20mb with 10.000 elements for example... if I use the removeAllObjects method...will its size be 0mb? 回答1: An NS[Mutable]Array is a collection of references to object. Calling -removeAllObjects

how to edit a plist programmatically in xcode 5 iOS 7?

耗尽温柔 提交于 2019-12-07 18:52:11
问题 how can I edit or change a value string from: in this plist I need change or Set "NO" in Enabled Value from Item 2, I see a lot examples, but not working, or are deprecated, or don't use ARC, any idea or example code? please help guys EDIT#1: I try this (not work) NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; path = [path stringByAppendingPathComponent:@"List.plist"]; NSFileManager *fileManager = [NSFileManager defaultManager];

Symbolic exception breakpoint on -[NSRangeException raise]

巧了我就是萌 提交于 2019-12-07 18:14:34
问题 Adding a symbolic breakpoint in Xcode gives you an example template of -[NSException raise] . I want to do the same thing but specifically on -[NSRangeException raise] . The reason being that I want to breakpoint only on specific array bounds exceptions, for example: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 31 beyond bounds [0 .. 30]' Yes, I know that I can add a catch all exception breakpoint. However, I do not want to

remove object from NSArray

烈酒焚心 提交于 2019-12-07 11:41:39
问题 How can I remove an object from a reversed NSArray . Currently I have a NSMutableArray , then I reverse it with NSArray* reversedCalEvents = [[calEvents reverseObjectEnumerator] allObjects]; now I need to remove at item from reversedCalEvents or calEvents and automatically refresh the table the array is displayed in based on conditions. i.e. if(someInt == someOtherInt){ remove object at index 0 } How can I do this? I cannot get it to work. 回答1: You will need a mutable array in order to remove

UIPickerView crashes app when user is spinning components at the same time

旧街凉风 提交于 2019-12-07 10:46:27
问题 I've got really unbearable issue with UIPickerView. There're 2 components: first one with food categories, and second with foods inside each category. I've got proper arrays with foods, which looks like: ViewController.h @property (strong, nonatomic) NSArray *leftPickerDataSource; @property (strong, nonatomic) NSArray *vegetablesDataSource; @property (strong, nonatomic) NSArray *eggsDataSource; @property (strong, nonatomic) NSArray *pastaDataSource; @property (strong, nonatomic) NSArray