nsdictionary

How can I get int values from the change dictionary in KVO method observeValueForKeyPath:ofObject:change:context:?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 13:20:05
问题 I am observing changes in the rate property of an AVPlayer by calling the following method on it like so: addObserver:sharedPlayerManagerInstance forKeyPath:@"rate" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:0]; The change dictionary I get back from observeValueForKeyPath:ofObject:change:context: is therefore: change = { kind: 1, new: 1, old: 0 } I checked the class of each value, and it turns out to be __NSCFNumber. However, when I try to convert [change

Convert NSString to NSDictionary separated by specific character

久未见 提交于 2019-12-24 12:03:05
问题 I need to convert this "5?8?519223cef9cee4df999436c5e8f3e96a?EVAL_TIME?60?2013-03-21" string into dictionary. Separated by "?" Dictionary would be some thing like { sometext1 = "5", sometext2 = "8", sometext3 = "519223cef9cee4df999436c5e8f3e96a", sometext4 = "EVAL_TIME", sometext5 = "60", sometext6 = "2013-03-21" } Thank you . 回答1: Break the string to smaller strings and loop for them. This is the way NSArray *objects = [inputString componentsSeparatedByString:@"?"]; NSMutableDictionary *dict

NSString hash collision doesn't mess up NSDictionary [closed]

半城伤御伤魂 提交于 2019-12-24 11:51:30
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . Run this code in the debugger and stop afterward (I'm in the iOS 7 simulator in Xcode 5.0.1). NSString *nsStr = @"/Users/123456789012/Library/Application Support/iPhone Simulator/7.0/Applications/94F31827-6DAD-4BD5-AC91-B215176265E1/Documents/libraries/shared/17517_abPub/OEBPS/indexes/Index.sqlite"

Nesting NSDictionary based on value

一世执手 提交于 2019-12-24 11:50:10
问题 i've data from Library that return this: NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:distanceNumber,@"distance",idChallengerN,@"idChallenger",dateFrom, @"date", nil]; [_array addObject:dict]; If i print _array this is there result: { date = "2015-07-31 14:50:40 +0000"; distance = "-1"; idChallenger = 43; }, { date = "2015-07-31 16:18:57 +0000"; distance = "-1"; idChallenger = "-1"; }, { date = "2015-07-31 16:19:05 +0000"; distance = "-1"; idChallenger = "-1"; }, and it's

Crash with exception attempt to insert nil object from objects[0]

梦想与她 提交于 2019-12-24 09:24:13
问题 I'm using NSDictionary to change the appearance of UIBarButtonItem in the appDelegate file: UIBarButtonItem *barButtonItemProxy = [UIBarButtonItem appearanceWhenContainedIn: [UINavigationBar class], [UINavigationController class], nil]; NSDictionary *textAttributes = @{UITextAttributeFont : [UIFont fontWithName:@"ChocoBold" size:13.0f], UITextAttributeTextColor : [UIColor whiteColor], UITextAttributeTextShadowColor : [UIColor blackColor], UITextAttributeTextShadowOffset : [NSValue

Is there any ordered dictionary collection in IOS 5?

半世苍凉 提交于 2019-12-24 09:14:57
问题 My issue is I am using the table data source from the dictionary. This dictionary contains more than 20 elements in it. I need to search the element present in the dictionary and I need to scroll that element to a visible cell. My issue is I found the element, but it is out of the visible area. I need to scroll that to a visible area. How can I get the index? 回答1: Short answer? Nope. I know the feeling though, which lead me to... Longer answer? Yes-ish? My search a little while back brought

ERROR: Memory Leak, data formatters temporarily unavailable

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 08:56:00
问题 I am developing a quiz app. I take questions from a xml file, parse it and display random questions. These are stored in NSdictionary and NSMutableArray. Also the app plays background music and sound for clicking of buttons(AVAudioPlayer). and vibration( AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)) In one particular function if i try to release the temp variables that I use(I.E NSDictionary and NSMutableArray) the app crashes wen i reach that function for the second time. Hence if i

How to get latitude and longitude of an image using PHAsset in iOS?

家住魔仙堡 提交于 2019-12-24 08:48:47
问题 I am trying to fetch images from photo library within the range of two dates and I am getting the images successfully. And I am also getting the info of the image by using below code. PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init]; options.networkAccessAllowed = YES; //download asset metadata from iCloud if needed [asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary

Getting data from array of dictionaries in an array

拈花ヽ惹草 提交于 2019-12-24 08:08:02
问题 I have created an Array of Dictionaries : let tempArray = [["id":"1","Name":"ABC"],["id":"2","Name":"qwe"],["id":"3","Name":"rty"],["id":"4","Name":"uio"]] Now I have to create an array of Name only. What I have done is this: var nameArray = [String]() for dataDict in tempArray { nameArray.append(dataDict["Name"]!) } But is there any other efficient way of doing this. 回答1: You can use flatMap (not map ) for this, because flatMap can filter out nil values (case when dict doesn't have value for

Easy way to put blank strings at end of sort using NSSortDescriptor?

牧云@^-^@ 提交于 2019-12-24 01:57:25
问题 I'm using NSSortDescriptor to sort an NSArray of NSDictionary items. Works great, just what I needed... except that I'd like for the dictionary items that have blank values for my sort key to show up at the end of the sorted list. Is there a way to easily accomplish this? Or will I have to create some custom sorting functions? And no, I don't want to just set it to DESC order... I'd like sorted results to look like A, A, B, B, C, blanks, blank. 回答1: Figured this out after seeing another