nsarray

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 2 beyond bounds for empty NSArray

╄→гoц情女王★ 提交于 2019-12-11 05:26:12
问题 Error in log: * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[ NSArray0 objectAtIndex:]: index 2 beyond bounds for empty NSArray' *** First throw call stack: ( 0 CoreFoundation 0x000000010fdd8b0b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00000001143a6141 objc_exception_throw + 48 2 CoreFoundation 0x000000010fdf027d -[__NSArray0 objectAtIndex:] + 93 3 DropInn 0x000000010d598fc4

NSDictionary add NULL keyvalue

坚强是说给别人听的谎言 提交于 2019-12-11 04:28:08
问题 So I am creating a NSDictionary that is feeding a method data to be used, but some of the key values in the keys array will not always be filled with values.. Say I have 18 keys (which I do).. I might only use 5 during one call but 6 in the other or even all 18 at some points in my code. What I would like to know is how can I add NULL values into those keys so later on when i look through the keyvalue pairs I can see which keys i need to worry about and which I can forget? so the question is,

Compare two arrays and put equal objects into a new array [duplicate]

ε祈祈猫儿з 提交于 2019-12-11 04:09:29
问题 This question already has answers here : Finding Intersection of NSMutableArrays (5 answers) Closed 5 years ago . How can I compare two NSArray s and put equal objects into a new array? 回答1: NSArray *array1 = [[NSArray alloc] initWithObjects:@"a",@"b",@"c",nil]; NSArray *array2 = [[NSArray alloc] initWithObjects:@"a",@"d",@"c",nil]; NSMutableArray *ary_result = [[NSMutableArray alloc] init]; for(int i = 0;i<[array1 count];i++) { for(int j= 0;j<[array2 count];j++) { if([[array1 objectAtIndex:i

NSArray (and other Cocoa types) @property values

和自甴很熟 提交于 2019-12-11 04:03:07
问题 While in the process of debugging code written by a co-worker, I stumbled across the following that has me mystified: NSMutableArray *array = [NSMutableArray array]; NSUInteger arrayCount = array.count; Why does this work? It also works for NSDictionary and other types, but nowhere in the documentation nor Cocoa headers can those @property definitions be found. Googling for "NSArray property" doesn't yield many useful results, so I'm reaching out to SO for what will surely be a very

Using JSON Framework on iPhone - HELP!

人走茶凉 提交于 2019-12-11 03:51:18
问题 Currently I am using the following code to parse the JSON link sent. This is how I also send a GET call to the Google Reader API for an upcoming iPhone application of mine. - (NSArray *)subscriptionList { if(!cookies && [cookies count] == 0) { [self requestSession]; } NSString * url = @"http://www.google.com/reader/api/0/subscription/list?output=json&client=scroll"; ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]]; [request setRequestMethod:@"GET"];

Sort NSArray with NSDate object into NSDictionary by month

时光总嘲笑我的痴心妄想 提交于 2019-12-11 03:36:21
问题 I am building a UITableView and would like to group by month so that I can have those strings as my section headers, e.g.: February 2013 - Item 1 - Item 2 January 2013 - Item 1 - Item 2 I have an NSArray which has custom objects that have a pubDate property that is an NSDate . How can I use that NSDate object to group my custom objects into a NSDictionary by month? 回答1: Sort array like this NSArray *sortedArray = [yourArrayOfCustomObjects sortedArrayUsingComparator:^NSComparisonResult(id obj1

Search from NSArray using Predicate

瘦欲@ 提交于 2019-12-11 02:58:26
问题 my current array looks like below. i create this array format for sectionIndex table. so i can search from array and display search text using index table. arrContent = ( { key = A; value = ( Ac, Acting ); }, { key = B; value = ( Basketball, Baseball ); }, { key = C; value = ( Cat ); } { key = P; value = ( Panda, Peacock ); } ) My Search code looks like below. and it is working fine. -(void)searchText:(NSString *) text { [arrSearch removeAllObjects]; for (int i = 0; i < [arrContent count]; i+

Getting objectId from parse.com

被刻印的时光 ゝ 提交于 2019-12-11 01:48:12
问题 So I am building an app that uses parse as a backend. I've written my own before but I figured I'll just save some time and use parse. I'm populating a table view with data from parse and that's fine. I want to grab the objectId from an dictionary built from an array from parse. The output of my array is as follows: <news_events:pdbIEvOteH:(null)> {\n eventDescription = \"This is a test description.\";\n eventMessage = \"This is a test message.\";\n eventTitle = \"Free Wi-Fi Now Available!\";

Subscript requires size of interface 'NSArray', which is not constant in non-stable ABI

耗尽温柔 提交于 2019-12-10 21:53:21
问题 I'm trying to send information to a server using ASIHTTPRequest and am setting the post values like this: for(int i = 0;i<13;i++){ [request setPostValue:propertyValues[i] forKey:propertyKeys[i]] } propertyValues and propertyKeys are both NSArray objects that hold 13 items each. When I run this, I get the error "Subscript requires size of interface 'NSArray', which is not constant in non-stable ABI" What does this mean? 回答1: It means you're trying to access an NSArray* as if it were an array,

iOS NSDictionary saved to NSUserDefaults not saving values

谁说胖子不能爱 提交于 2019-12-10 20:47:47
问题 I am trying to save a NSDictionary with array values to NSUserDefaults but am having some strange trouble. My NSDictionary has NSStrings for keys and each value is a NSArray of NSNumbers . When I print the dictionary out, everything is fine. I write this dictionary to NSUserDefaults and if I read it back out right away, everything seams fine. Using this everything seams just fine: [[NSUserDefaults standardUserDefaults] setObject:self.selectedOptionPositions forKey:PREF_OPTIONS_KEY]; [