?
Solved

Converting  guid as a null-termintated string binary to hex

Posted on 2014-01-09
2
Medium Priority
?
855 Views
Last Modified: 2016-02-29
Hi All,

I have a GUID : 373D06E9-587E-4930-B846-12500FF1AC2F which needs to be converted into hexadecimal using Cocoa or objective C.



Can some one please let me know how to do that.

Thanks,
Ravi
0
Comment
Question by:rkankula
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 1500 total points
ID: 39770610
GUID is 128-bit value displayed as 32 hexadecimal digits.
I hope this example will help you:
        NSString *source = @"373D06E9-587E-4930-B846-12500FF1AC2F";
        NSString *line = [source stringByReplacingOccurrencesOfString:@"-" withString:@""];
        NSUInteger length = [line length];
        
        NSUInteger cnt = 0;
        unichar symbols[2];
        while ( cnt < length ) {
            symbols[0] = [line characterAtIndex:cnt];
            symbols[1] = [line characterAtIndex:cnt + 1];
            NSString *one = [NSString stringWithCharacters:symbols length:2];
            
            NSScanner *scanner = [NSScanner scannerWithString:one];
            unsigned hexNum;
            [scanner scanHexInt:&hexNum];
            
            NSLog(@"0x%@ %i", one, hexNum);
            
            cnt += 2;
        }

Open in new window

0
 

Author Closing Comment

by:rkankula
ID: 39771771
Thanks this will be helpful
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating an installable image of an iPhone mobile app (an .ipa file) that beta testers could load onto their test devices. The process involved quite a few steps, but both Appcelerator and Diawi.org had decent …
What's a UDID? If you're involved in developing, testing, or even reviewing an iOS application that's in beta, then at some point you may need to know the UDID for any iOS devices that you'll be testing on. What's the UDID? It stands for Unique Dev…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question