objective c - iOS how to print the equivalent of "view memory of * " in xCode? -



objective c - iOS how to print the equivalent of "view memory of * " in xCode? -

i'm trying print out "issuer" info available keychain item in ios. can't seem find proper encoding or understand how info stored.

when take thew "view memory of*" alternative in xcode, see see text among garbage. i'm trying understand how can print both text , garbage memory pointer addressing. below screenshot of i'm trying do

i tried these, either nil strings, or japaneese characters utf16

id info = [innerobject objectforkey:@"issr"]; nsstring* string8 = [[nsstring alloc] initwithdata:data encoding:nsutf8stringencoding]; nsstring* string16 = [[nsstring alloc] initwithdata:data encoding:nsutf16stringencoding]; nsstring* string16be = [[nsstring alloc] initwithdata:data encoding:nsutf16bigendianstringencoding]; nsstring* string16le = [[nsstring alloc] initwithdata:data encoding:nsutf16littleendianstringencoding]; nsstring* string32 = [[nsstring alloc] initwithdata:data encoding:nsutf32stringencoding]; nsstring* string8bytes = [[nsstring alloc]initwithbytes:&data length:[data length] encoding:nsutf8stringencoding]; //nslog result

looking @ memory dump, can select letters , highlight corresponding memory bytes. there 2 bytes per letter, made me realize using ascii encoding, code below works:

@try { if([data iskindofclass:[nsdata class]]==no) { continue; } nsstring* stringascii = [[nsstring alloc] initwithdata:data encoding:nsasciistringencoding]; nscharacterset* alphanumeric = [nscharacterset charactersetwithcharactersinstring:@"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz01234567890.@"]; nscharacterset *donotwant = [alphanumeric invertedset]; nsstring* cleanedupstring = [[stringascii componentsseparatedbycharactersinset: donotwant] componentsjoinedbystring: @" "]; if(cleanedupstring.length>0) { dlog(@" %@ cleaned up: %@",key,cleanedupstring); } } @catch (nsexception *exception) { } @finally { }

ios objective-c xcode nsstring nsdata

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -