nsarray

Simple NSTableView bindings example

二次信任 提交于 2019-12-24 07:26:21
问题 I am trying to populate a 2-column NSVTableView via bindings, but the data is not showing up in the table. In XCode: I have a NSMutableArray in my AppDelegate that will hold the data, as well as the corresponding @property and @synthesize. On an event, I call [removeAllObjects] on the NSMutableArray and repopulate it with some NSDictionary objects. Each dictionary contains 2 KVP's: a NAME and a VALUE. In IB: I added an NSArrayController and bound it's Content Array to my AppDelegate and set

how to remove spaces, brackets and " from nsarray

亡梦爱人 提交于 2019-12-24 06:44:49
问题 I have an array where i am trying to remove the access spaces, brackets and " from the nsarray in order to use componentsSeparatedByString:@";" NSArray *paths = [dic valueForKey:@"PATH"]; for(NSString *s in paths) { NSLog(@"String: %@", s); } String: ( "29858,39812;29856,39812;29800,39819;29668,39843;29650,39847;29613,39855;29613,39855;29613,39856;29605,39857;29603,39867;29603,39867;29599,39892;29596,39909;29587,39957;29571,40018;29563,40038;29560,40043" ) this is the output give as show

How to sort an array of NSStrings by the number contained within? (in ascending order)

隐身守侯 提交于 2019-12-24 05:21:48
问题 I'm wondering if it is possible to sort an NSArray of NSStrings based on a number value contained within. Basically its a list of process ID's and process names, and I would like to sort the processes based on their process ID. The array looks like this : "286 Google Chrome He", "1209 ibtool", "0 kernel_task", "1 launchd", "10 kextd", "11 notifyd", "12 diskarbitrationd", "13 configd", "14 syslogd", "15 DirectoryService", "16 distnoted", "18 ntpd", "22 SystemStarter", "25 securityd", "28 mds",

How to sort an array of NSStrings by the number contained within? (in ascending order)

廉价感情. 提交于 2019-12-24 05:21:03
问题 I'm wondering if it is possible to sort an NSArray of NSStrings based on a number value contained within. Basically its a list of process ID's and process names, and I would like to sort the processes based on their process ID. The array looks like this : "286 Google Chrome He", "1209 ibtool", "0 kernel_task", "1 launchd", "10 kextd", "11 notifyd", "12 diskarbitrationd", "13 configd", "14 syslogd", "15 DirectoryService", "16 distnoted", "18 ntpd", "22 SystemStarter", "25 securityd", "28 mds",

NSPredicate for property of object in NSArray of NSArray

风流意气都作罢 提交于 2019-12-24 03:44:09
问题 I have an objects like the below structure: Transaction has an array of Items. Item has an array of SubItems @interface Transaction : NSObject @property (nonatomic, copy) NSString *id; @property (nonatomic, assign) NSInteger status; @property (nonatomic, strong) NSArray *items; // array of Item @end @interface Item : NSObject @property (nonatomic, copy) NSString *identifier; @property (nonatomic, assign) NSInteger price; @property (nonatomic, strong) NSArray *subitems; @end @interface SubItem

Filter NSArray with NSPredicate

笑着哭i 提交于 2019-12-24 01:17:01
问题 I want to filter an array of User objects ( User has fullname , user_id and some more attributes..) according to firstName or lastName that begin with some string. I know how to filter according to one condition: NSPredicate* predicate = [NSPredicate predicateWithFormat:@"firstName BEGINSWITH[cd] %@", word]; NSArray* resArr = [myArray filteredArrayUsingPredicate:predicate]; this will give me all the users that has a firstName that starts with "word". But what if I want all the users that has

Adding Multiple NSArrays to NSMutableDictionary with corresponding matching item in array order

て烟熏妆下的殇ゞ 提交于 2019-12-24 00:32:15
问题 I have two arrays say itemName and itemImages NSArray *itemName = @[@"Blog", @"Missions", @"Subscriptions", @"Questions", @"Aide",@"Disconnect"]; NSArray *itemImages = @[@"ico-1",@"ico-2", @"ico-3", @"ico-4", @"ico-5", @"ico-6"]; I need to add them to a dictionary NSMutableDictionary *menuItemNameImage = [[NSMutableDictionary alloc] init]; [menuItemNameImage setValue:itemName forKey:@"itemName"]; [menuItemNameImage setValue:itemImages forKey:@"itemImages"]; NSLog(@"%@", menuItemNameImage);

NSArray mutability and arrayByAddingObject

我怕爱的太早我们不能终老 提交于 2019-12-23 19:55:36
问题 I thought I had a good understanding of Objects and mutability in Objective-C but I've noticed something curious with NSArray . If I have the following that doesn't work: NSArray *myArray = [ [[NSUserDefaults standardUserDefaults] arrayForKey:someKey] arrayByAddingObject:myObject ]; "myObject" is never added to "myArray" . However, the following works: NSArray *someArray = [[NSUserDefaults standardUserDefaults] arrayForKey:someKey]; NSArray *myArray = [someArray arrayByAddingObject:myObject];

predicateWithFormat vs stringWithFormat: is the former supposed to do the same as the latter?

半城伤御伤魂 提交于 2019-12-23 18:23:27
问题 I have an array with file names and I want to find all the names that end with e.g. 00001.trc when traceNum is 1. I tried this: NSPredicate *tracePredicate = [NSPredicate predicateWithFormat:@"SELF ENDSWITH \"%05d.trc\"", traceNum]; and my predicate was SELF ENDSWITH "%05d.trc" instead of SELF ENDSWITH "00001.trc" I tried this: NSPredicate *tracePredicate = [NSPredicate predicateWithFormat:@"SELF ENDSWITH %@%05d.trc%@", @"\"", traceNum, @"\""]; and I got an exception: Unable to parse the

Writing array contents to a file

╄→гoц情女王★ 提交于 2019-12-23 13:19:09
问题 I've struggled with this all day using answers from here, but I cannot find a solution that is working for me, so I thought I'd ask for help: I have an array of objects that I've extracted from an entity. All I want to do is to write the objects to a file. What I've come up with so far is this: NSLog(@" Exported Records: %i", [exportArray count]); // the count here is 4 records. //Each record has about 8 elements. //I'm just trying to get this working with the first two elements right now