nsmutablearray

Faster sort of NSMutableArray of MPMediaItems? Code Review

二次信任 提交于 2019-12-04 16:52:48
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 playlist ("Last 4 months") and will then build my own array of collections. As I say, the approach below

Comparing NSMutableArray Elements for Values

末鹿安然 提交于 2019-12-04 16:47:57
I am looking for a way to compare the contents of two NSMutableArray objects. Both arrays are filled with NSMutableDictionaries which were allocated separately but occasionally contain the same data. Simplified Example: NSMutableArray *firstArray = [[NSMutableArray alloc] init]; NSMutableArray *secondArray = [[NSMutableArray alloc] init]; NSMutableDictionary *a = [[NSDictionary alloc] init]; [a setObject:@"foo" forKey:"name"]; [a setObject:[NSNumber numberWithInt:1] forKey:"number"]; NSMutableDictionary *b = [[NSDictionary alloc] init]; [b setObject:@"bar" forKey:"name"]; [b setObject:

How to add an NSMutableArray to an NSMutableArray Objective-c

安稳与你 提交于 2019-12-04 15:46:54
问题 I am making the switch from Java to Objective-c, and I'm having some difficulty. I have searched this problem this without much success. I have an NSMutableArray that stores NSMutableArrays. How do I add an array to the array? 回答1: You can either store a reference to another array (or any type of object) in your array: [myArray addObject:otherArray]; Or concatenate the arrays. [myArray addObjectsFromArray:otherArray]; Both of which are documented in the documentation. 回答2: Since an array is

problem writing a NSMutableArray to file in cocoa

匆匆过客 提交于 2019-12-04 13:47:40
问题 A real beginners question. I have a NSView subclass in which I create a NSMutableArray containing NSValues. When I want to write the array to a file using writetofile:atomatically: the file is created but it contains none of the NSValues that the mutable array does contain. Does anyone know how I successfully can write this mutable array to a file? Thanks 回答1: NSValues can't be saved in a plist (which is what writeToFile:atomically: does). Take a look here for the values you can save.

NSMutableArray collection and @Synchronized blocks

回眸只為那壹抹淺笑 提交于 2019-12-04 13:14:44
问题 In Objective C I'm using a NSMutableArray instance from various thread and I'm using @synchronized to make it thread safe. currently all my acces to this array are protected with a @synchronized block, even objectAtIndex: method. Nevertheless I wonder which methods call really need to be protected with @synchronized. do I need to protect read access ? What would happens if 'ObjectAtIndex' is not protected and called at the same time that 'removeObject' ? If all methods are protected by a

How to check a uiviewcontroller is present in uinavigationcontroller stack

北战南征 提交于 2019-12-04 12:56:09
I have a UINavigationController . I have to pop a view from a UINavigationController and replace it with another view. How we can search for a UIViewController object and replace it with another ? when i print NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray: myDelegate.navigationController.viewControllers]; I tried.. [allViewControllers removeObjectIdenticalTo: @"NonLogginedViewController"]; [allViewControllers removeObjectIdenticalTo: myDelegate.nonLogginedViewController]; myDelegate.navigationController.viewControllers = allViewControllers; But it didn't update the

Searching through an array of dictionaries

戏子无情 提交于 2019-12-04 12:55:24
I'm making an iPhone app which displays information about red wines. The wines are stored in a plist containing an array of dictionaries. I'm adding a search view controller to the application, and to start up easy I want to get the wines who the value for the "Name" key contains nameString (from textbox). It kind of stops here, I need some advices about the most suitable way of doing this. Is there a function in the NSArray class which will do the job, should bring in NSPredicate, NSUserDefaults, or are there other options? I've done some research but I'm going to need some advices and maybe

iPhone/iOS How to load a lot of image in many folder and show in a table view?

爷,独闯天下 提交于 2019-12-04 12:55:23
I got annoying question... What if I have many image , and I want load it in to a table view And show the file name as cell's text , and the preview image is also show in the cell. When I select the cell , it will push to next view , show the big size image. That's it . I don't know how to load many folder to an array? /*********** EDIT ***********/ This is the folder I set many images inside You can see that's only one root folder ... And this is my code to load the image inside NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *filePath = [[NSBundle mainBundle]

How do I alphabetically sort a custom object field within a NSMutable Array?

可紊 提交于 2019-12-04 11:42:42
问题 I have a custom object like: #import <Foundation/Foundation.h> @interface Store : NSObject{ NSString *name; NSString *address; } @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *address; @end I have an array of NSMutableArray (storeArray) containing Store objects: store1 = [[Store alloc] init]; store1.name = @"Walmart"; store1.address = @"walmart address here.."; store2 = [[Store alloc] init]; store2.name = @"Target"; store2.address = @"Target address here

Split NSArray into sub-arrays based on NSDictionary key values

天涯浪子 提交于 2019-12-04 11:37:47
We have an app that calls a SOAP web service and retrieves a long list of XML, which the app then parses into an NSArray of NSDictionary objects. The NSArray contains a list of Rental Apartment information, each of which is stored into an NSDictionary . The entire list may contain 10 different types of Apartments (i.e. 2-room, 3-room), and we need to split the NSArray into smaller NSArray s based on Room-Type, which has the key "roomType" in the NSDictionary objects. Currently our algorithm is Use [NSArray valueForKeyPath:@"@distinctUnionofObjects.room-type"] to obtain a list of unique room