nsdictionary

calling a method when a particular CCAnimationFrame is displayed using CCAnimationFrameDisplayedNotification

拜拜、爱过 提交于 2019-12-11 04:46:23
问题 I would like to call a method that rotates a sprite when a particular frame in displayed. I got a few ideas from this post but I am having issues as to how I should implement it. How would I define my dictionary for accessing 3rd frame and link it to the selector? Below is what I've done. Please note that it's work-in-progress. -(id) init { // always call "super" init // Apple recommends to re-assign "self" with the "super's" return value if( (self=[super init]) ) { CCSpriteBatchNode*

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,

iOS/Swift 1.2 NSDictionray/Dictionary on NSStandardUserDefaults

随声附和 提交于 2019-12-11 04:04:49
问题 In the 'old' Swift, I used to register my defaults loaded from a .plist file like this... let prefs = NSBundle.mainBundle().pathForResource("UserDefaults", ofType: "plist"); let dict = NSDictionary(contentsOfFile: prefs!); let defaults:NSDictionary! = dict?.valueForKey("defaults") as! NSDictionary; NSUserDefaults.standardUserDefaults().registerDefaults(defaults); NSUserDefaults.standardUserDefaults().synchronize(); Under Swift 1.2, I get the error... Cannot invoke 'registerDefaults' with an

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

Remove values from dictionary in iOS swift

廉价感情. 提交于 2019-12-11 03:48:35
问题 I have a JSON object as such: The Result { shops = ({ date = "2015-07-22T14:14:48.867618"; "num_items" = 0; score = "-1"; "total_spend" = 0; }, { date = "2015-07-22T14:17:03.713194"; "num_items" = 1; score = 5; "total_spend" = "1.85"; }); } And My Code: let dict = result as! NSDictionary var mutDict: NSMutableDictionary = dict.mutableCopy() as! NSMutableDictionary for (key, value) in mutDict { for i in 0..<backendArray.count { if value[i].objectForKey("num_items") === 0 { //delete that shop

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

iOS: setting alphas of multiple buttons at once

£可爱£侵袭症+ 提交于 2019-12-11 03:02:47
问题 Okay, so I don't really know if NSDictionary is the correct approach to this, but I am using a fade animation to take different groups of buttons on and off a screen. I want to "compartmentalize" them, so to speak, into different groups so I can do this in one or two lines without having to rewrite all the buttons names every time (there are a good amount). Any ideas on how to do this? [UIView animateWithDuration: 1.5 animations: ^(void) { //As an example i just called them button1, button2,

iOS objective-c - JSON String to NSDictionary Exception

邮差的信 提交于 2019-12-11 02:32:28
问题 I'm relatively new to Objective-C, and followed a tutorial on an introduction to MapKit (located here). I've been trying to debug an issue with a JSON string being passed to an NSDictionary. I'm getting the following error: 2012-08-13 11:18:30.370 ArrestsPlotter[76578:c07] -[__NSCFString JSONValue]: unrecognized selector sent to instance 0x73a6400 2012-08-13 11:18:30.372 ArrestsPlotter[76578:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_

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!\";

Objective-C at sign and curly braces, @{ … } what does it mean?

本小妞迷上赌 提交于 2019-12-11 01:23:30
问题 I have this line in Objective-C. NSMutableArray *mutableArray; [mutableArray addObject:@{ @"Something" : aObject, @"Otherthing" : anotherObject }]; What does the @{ ... } part do exactly? It is an object, but it seems to create some kind of key, value pair on the fly. 回答1: It is creating NSDictionary object as you said. Syntax is simple NSDictionary* dictionary = @{key: object, key: object}; In your example, keys are objects of NSString class. It is important to remember that dictionary