Re: base64 NSData to NSString
On Mar 22, 2008, at 9:24 PM, Jens Alfke wrote: On 22 Mar '08, at 1:19 PM, Marco Cassinerio wrote: I've done what you said, but nothing changed. I get the same data content, like this: ImgR\362FBIL\346\326\303\331\376\247H+\222!\222C\303\351-+ \377\376\377\377\377\377\222!\221\302\221\301 \2161\216a mfile.icnsMacintosh HD>Developer/Applications/Xcode.app/Contents/ Resources/mfile.icns/\377\377 That's not base64. If I recall, you're looking at file aliases in a plist? In that case, what you have is an NSData object containing the raw data from an AliasHandle. You'll need to copy that into a handle, and use the CoreServices API to get an FSRef or path to the destination file. Actually, there are a couple of existing Cocoa wrappers for the Aliases API, and I'd recommend finding and using one of those instead, unless you're really familiar with Carbon concepts like handles and FSRefs. —Jens Thank you. I found NDAlias http://homepage.mac.com/nathan_day/pages/source.xml on the network and it works fine. Marco ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: base64 NSData to NSString
On 22 Mar '08, at 1:19 PM, Marco Cassinerio wrote: I've done what you said, but nothing changed. I get the same data content, like this: ImgR\362FBIL\346\326\303\331\376\247H+\222!\222C\303\351-+ \377\376\377\377\377\377\222!\221\302\221\301 \2161\216a mfile.icnsMacintosh HD>Developer/Applications/Xcode.app/Contents/ Resources/mfile.icns/\377\377 That's not base64. If I recall, you're looking at file aliases in a plist? In that case, what you have is an NSData object containing the raw data from an AliasHandle. You'll need to copy that into a handle, and use the CoreServices API to get an FSRef or path to the destination file. Actually, there are a couple of existing Cocoa wrappers for the Aliases API, and I'd recommend finding and using one of those instead, unless you're really familiar with Carbon concepts like handles and FSRefs. —Jens smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: base64 NSData to NSString
On Mar 22, 2008, at 8:46 PM, Jens Alfke wrote: On 22 Mar '08, at 12:40 PM, Marco Cassinerio wrote: Using NSPropertyListSerialization means that the .plist file is a binary representation and not an XML representation, is it true? No. You can choose either format when writing a plist, and when reading a plist it automatically detects the type and reads either one. Provided you use plist APIs to read the property lists, you shouldn't have to care what format they're in. You'll get a collection of objects and can work with them directly. —Jens I've done what you said, but nothing changed. I get the same data content, like this: ImgR\362FBIL\346\326\303\331\376\247H+\222!\222C\303\351-+ \377\376\377\377\377\377\222!\221\302\221\301 \2161\216a mfile.icnsMacintosh HD>Developer/Applications/Xcode.app/Contents/ Resources/mfile.icns/\377\377 I've tried to write a parser, but is very hard. Marco ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: base64 NSData to NSString
On 22 Mar '08, at 12:40 PM, Marco Cassinerio wrote: Using NSPropertyListSerialization means that the .plist file is a binary representation and not an XML representation, is it true? No. You can choose either format when writing a plist, and when reading a plist it automatically detects the type and reads either one. Provided you use plist APIs to read the property lists, you shouldn't have to care what format they're in. You'll get a collection of objects and can work with them directly. —Jens smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: base64 NSData to NSString
>They aren't "base64 NSData objects", they are NSData objects which >happen to be stored using base64. This is an implementation detail and >you shouldn't need to care about it. >The .plist extension implies that these are property lists. You can >read them with NSPropertyListSerialization. This will take care of >decoding the NSData objects however they are represented, and will >also do nice things like not fail utterly when Apple decides that this >plist should be stored using the binary format instead of the XML >format. >Mike I'm a bit confused. Property list documentation says "Data bytes are base-64 encoded between the and tags." Using NSPropertyListSerialization means that the .plist file is a binary representation and not an XML representation, is it true? Marco ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: base64 NSData to NSString
On Sat, Mar 22, 2008 at 1:22 PM, Marco Cassinerio <[EMAIL PROTECTED]> wrote: > Hi, > > i'm trying to read the com.apple.recentitems.plist file and i found > that "Alias" and "Icon" key are base64 NSData object. > NSData and NSString don't provide methods to manage base64 data. They aren't "base64 NSData objects", they are NSData objects which happen to be stored using base64. This is an implementation detail and you shouldn't need to care about it. The .plist extension implies that these are property lists. You can read them with NSPropertyListSerialization. This will take care of decoding the NSData objects however they are represented, and will also do nice things like not fail utterly when Apple decides that this plist should be stored using the binary format instead of the XML format. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: base64 NSData to NSString
I really wouldn't do it this way. There are many ways of doing this within your app without spawning a task. LibCrypto offers functions for encoding and decoding Base64 as does LibSSL (which is going to be the same code as you're currently trying to use, but without spawning a task). There are also several categories on NSData floating around out there that will allow you to decode and encode Base64 right in your application, some of which are very well tested. You can find some good discussion on the topic here: http://www.cocoadev.com/index.pl?BaseSixtyFour The category from Colloquy that is discussed has moved to a new location. You can find it at its new location here: http://colloquy.info/project/browser/trunk/Additions/NSBundleAdditions.h http://colloquy.info/project/browser/trunk/Additions/NSBundleAdditions.m HTH Jeff On Mar 22, 2008, at 1:22 PM, Marco Cassinerio wrote: i'm trying to read the com.apple.recentitems.plist file and i found that "Alias" and "Icon" key are base64 NSData object. NSData and NSString don't provide methods to manage base64 data. I've searched with Google and i found some "pathces" for NSString and NSData but they don' t seem to work. I've also tried to write NSData object content to file and pass it to openssl command from bash: openssl base64 -d -in in.txt -out out.txt but it always create a blank file. Any suggestions? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: base64 NSData to NSString
Marco, > I've searched with Google and i found some "pathces" for NSString and NSData > but they > don' t seem to work. I've used the one contained in Eric Czarny's XML-RPC library, and it seems to work: http://sourceforge.net/projects/xml-rpc/ That is based on: http://ranchero.com/cocoa/xmlrpc/ Note that there, the methods are implemented as class methods, and they're categories (this is the right name, not "patches") of NSString (for encoding) and NSData (for decoding). Paolo ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]