ios - Using the object returned from getObject in NSMutableDictionary -


I'm an Obj-C newbie, so this could be a clear question.

I am adding 10 numbers as keys to an NSMutableDictionary, for all of those 0 value such as -

  (i = 1; i & Lt; 10; i ++) {{dict set object: [NSNumber number: 1] for KA: [NSNumber numberat: i]]; }  

Now in the code later I want to get the object for the key number and I want to get the value of it. In this case for example, we store the value 0 for the number 3. I use this code for this -

  ID number obz = [game object foreaki: [nsnumber number: 3]]; Int numbersobject value = ????  

I see the ID in the debugger pointing to 0. But I'm not sure how to declare it in the integer variable, I declare it. Hope that makes sense.

I print numbers oz and some address is expected as print, how do I change this general ID into an NSNumber and store it in the number objectview later?

id is not a datatype, its simple meaning is that any Also can return the object type when you are certain that you have inserted NSNumber , then you in a NSNumber Can get it.

  NSNumber * myNumber = [myDict objectForKey: key];  

That's it. If you want to make sure that it is actually returning a NSNumber , then use isKindOfClass: .


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -