Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 941899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:11:15+00:00 2026-05-15T22:11:15+00:00

I would like to access some values from a CFMutableDictionaryRef and then do some

  • 0

I would like to access some values from a CFMutableDictionaryRef and then do some math on them. Using the code below I have managed to print some properties of my battery. I am also able to print out single values (although in doing so I get a warning:invalid receiver type:CFMutableDictionaryRef).

Then I try to convert the string values to NSNumber and then the program bugs. It gives me something like unrecognized selector sent to instance 0x5d65f70 Any help?

CFMutableDictionaryRef matching , properties = NULL;
io_registry_entry_t entry = 0;
matching = IOServiceMatching( "IOPMPowerSource" );
//matching = IOServiceNameMatching( "AppleSmartBattery" );
entry = IOServiceGetMatchingService( kIOMasterPortDefault , matching );
IORegistryEntryCreateCFProperties( entry , &properties , NULL , 0 );

NSLog( @"%@" , properties );


NSString * voltage = [properties objectForKey:@"Voltage"];  
NSString * currentCapacity = [properties objectForKey:@"CurrentCapacity"];  


NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber * myNumber = [f numberFromString:voltage];


[f release];
CFRelease( properties );
IOObjectRelease( entry );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:11:15+00:00Added an answer on May 15, 2026 at 10:11 pm

    I am also able to print out single values (although in doing so I get a warning:invalid receiver type:CFMutableDictionaryRef).

    That’s because the compiler doesn’t know that CFMutableDictionaries are also NSMutableDictionaries. You’ll have to use an explicit cast to tell the compiler that sending messages to the dictionary is OK. Either that, or use CFDictionaryGetValue instead (CFMutableDictionary is a subclass of CFDictionary).

    Then I try to convert the string values to NSNumber and then the program bugs. It gives me something like unrecognized selector sent to instance 0x5d65f70

    It would help to tell us:

    • What selector wasn’t recognized
    • What kind of object 0x5d65f70 was at the time
    • What line of your program caused the exception (the debugger will tell you this if you run your application under it)

    At a guess, you might check whether the object for the Voltage key really is a string by logging the object’s class. It might already be a number. It’s reasonable to assume that anything that expects an NSString will try to send NSString messages to whatever you give it, so if you give it an NSNumber, you’ll have it sending NSString messages to an NSNumber object, which is one possible cause of that exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use ConfigurationManager to access some string values from a static
I would like to set some values in context.xml file and access the same
I would like to know if there is some way to access the values
I have a case here that I would like to have some opinions from
I would like to define and initialize some variables in web.xml and the access
I would like to access skyDrive using PHP. I want to retreive list of
I would like to access a MySQL database using PHP. Can someone please explain
I have an IEnumerable object. I would like to access based on index for
I would like to have access to the Seconds_Behind_Master field, (as returned by SHOW
I would like to insert some data into an Access Database. DataTable dt =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.