Re: Creating a Bundle via Code
On Jun 20, 2008, at 4:43 PM, Grant Limberg wrote: Is there a way to create a new bundle from in Cocoa? What I'd like to do is have a bundle in my app's Application Support folder to store some data generated by the user in my app. Since it's just data, I think you want a package rather than a bundle, as such. A package is a directory which the Finder and other system GUI presents to the user as a file. Do I simply just create a folder and set a bit on it that the OS identifies as being a bundle or is there anything else special I have to do? Sort of. You don't set a bit on the folder. You declare a document type in your application's Info.plist. That document type would specify your custom folder name extension and indicate that it's a package document type. This informs Launch Services (and the Finder, which relies on LS) that the folder is a package. See the Bundle Programming Guide. In particular, see the chapter on Document Packages, but don't limit yourself to that chapter. http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/ http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/Concepts/DocumentBundles.html Cheers, Ken ___ 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: Creating a Bundle via Code
This might help: http://www.cimgf.com/2008/05/13/from-hacker-to-microisv-custom-file-formats/ In essence you create a folder and set attributes on it as you suspected. Though these are referred to as packages instead of bundles. Take a look at NSFileManager. You can create a directory that hides the file extension. You then have your open and save panels treat the file as a single file rather than a directory. You can also register a file extension with the OS so that when the file/bundle is double clicked it will open in your app. Not sure if that's exactly what you wanted, but I'm not sure your storing user generated data this way in the Application Support folder is the best approach either. You probably want to support saving to files or use Core Data instead if you don't want custom file formats. -Matt On Jun 20, 2008, at 3:43 PM, Grant Limberg wrote: Is there a way to create a new bundle from in Cocoa? What I'd like to do is have a bundle in my app's Application Support folder to store some data generated by the user in my app. I see plenty of methods to call to load bundles and check if a folder is a bundle, but not creating them. Do I simply just create a folder and set a bit on it that the OS identifies as being a bundle or is there anything else special I have to do? Thanks in advance, Grant Limberg [EMAIL PROTECTED] LinkedIn: http://www.linkedin.com/in/grantlimberg http://www.glsoftware.net ___ 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/matt.long%40matthew-long.com This email sent to [EMAIL PROTECTED] ___ 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: Creating a Bundle via Code
Initially I was storing the data in Core Data. In my app, the user has the ability to attach an image to a record in Core Data. Unfortunately, changing from a JPEG to NSData inflates a 1.5MB JPEG to over 20 MB. In talking with some folks at the local Cocoaheads meeting on wednesday, one person suggested making a bundle or package in Application Support to store the images and just have a referencing URL in the Core Data store. This is what I'm trying to do now. Grant Limberg [EMAIL PROTECTED] LinkedIn: http://www.linkedin.com/in/grantlimberg http://www.glsoftware.net On Jun 20, 2008, at 3:22 PM, Matt Long wrote: This might help: http://www.cimgf.com/2008/05/13/from-hacker-to-microisv-custom-file-formats/ In essence you create a folder and set attributes on it as you suspected. Though these are referred to as packages instead of bundles. Take a look at NSFileManager. You can create a directory that hides the file extension. You then have your open and save panels treat the file as a single file rather than a directory. You can also register a file extension with the OS so that when the file/ bundle is double clicked it will open in your app. Not sure if that's exactly what you wanted, but I'm not sure your storing user generated data this way in the Application Support folder is the best approach either. You probably want to support saving to files or use Core Data instead if you don't want custom file formats. -Matt On Jun 20, 2008, at 3:43 PM, Grant Limberg wrote: Is there a way to create a new bundle from in Cocoa? What I'd like to do is have a bundle in my app's Application Support folder to store some data generated by the user in my app. I see plenty of methods to call to load bundles and check if a folder is a bundle, but not creating them. Do I simply just create a folder and set a bit on it that the OS identifies as being a bundle or is there anything else special I have to do? Thanks in advance, Grant Limberg [EMAIL PROTECTED] LinkedIn: http://www.linkedin.com/in/grantlimberg http://www.glsoftware.net ___ 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/matt.long%40matthew-long.com This email sent to [EMAIL PROTECTED] ___ 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: Creating a Bundle via Code
On Jun 20, 2008, at 3:28 PM, Grant Limberg wrote: Initially I was storing the data in Core Data. In my app, the user has the ability to attach an image to a record in Core Data. Unfortunately, changing from a JPEG to NSData inflates a 1.5MB JPEG to over 20 MB. In talking with some folks at the local Cocoaheads meeting on wednesday, one person suggested making a bundle or package in Application Support to store the images and just have a referencing URL in the Core Data store. This is what I'm trying to do now. It doesn't sound to me that you actually need to have a bundle. You can just store the image data as files in the file system. I'm also curious as to why you decompress the JPEG file? If you got the image as a compressed JPEG, why not store it as is? j o a r ___ 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: Creating a Bundle via Code
On 2008 Jun, 20, at 15:28, Grant Limberg wrote: Initially I was storing the data in Core Data. In my app, the user has the ability to attach an image to a record in Core Data. Unfortunately, changing from a JPEG to NSData inflates a 1.5MB JPEG to over 20 MB. I was planning on doing something like that, but your results indicate a serious problem with Core Data if you've got very many of those images. Are you storing it as an attribute of type Transformable, and not specifying a transformer so that it uses the default/archiver? Jerry ___ 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: Creating a Bundle via Code
As far as I know, you can't store a raw jpeg in Core Data directly without turning it into an NSData object first which in turn decompresses it. Someone correct me if I'm wrong! Grant Limberg [EMAIL PROTECTED] LinkedIn: http://www.linkedin.com/in/grantlimberg http://www.glsoftware.net On Jun 20, 2008, at 3:38 PM, j o a r wrote: On Jun 20, 2008, at 3:28 PM, Grant Limberg wrote: Initially I was storing the data in Core Data. In my app, the user has the ability to attach an image to a record in Core Data. Unfortunately, changing from a JPEG to NSData inflates a 1.5MB JPEG to over 20 MB. In talking with some folks at the local Cocoaheads meeting on wednesday, one person suggested making a bundle or package in Application Support to store the images and just have a referencing URL in the Core Data store. This is what I'm trying to do now. It doesn't sound to me that you actually need to have a bundle. You can just store the image data as files in the file system. I'm also curious as to why you decompress the JPEG file? If you got the image as a compressed JPEG, why not store it as is? j o a r ___ 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: Creating a Bundle via Code
On Jun 20, 2008, at 3:43 PM, Grant Limberg wrote: As far as I know, you can't store a raw jpeg in Core Data directly without turning it into an NSData object first which in turn decompresses it. It sounds quite possible that Core Data only support images in the form of NSData. That said, I see no reason why you would have to decompress the JPEG to generate this NSData. We need to know more about your application to provide more detailed assistance. Where do you get your JPEG images from? Over the network? From files in the file system? Pasted into an image view by the user? It sounds like you go from JPEG - NSImage - NSData? Instead of creating a NSImage, how about just storing the JPEG as is to the file system first, and only later generating NSImages as needed for display in your application. j o a r ___ 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: Creating a Bundle via Code
Currently, the user drags an existing image from their filesystem to an NSImageView bound to an NSData attribute in the sqlite data store. This causes the decompression from 1.5MB to 20MB. As you can see, this isn't exactly efficient. Hence the question on package/bundle creation. I'm wanting to just store the jpeg directly to disk and just store a URL to it in the sqlite data store. Grant Limberg [EMAIL PROTECTED] LinkedIn: http://www.linkedin.com/in/grantlimberg http://www.glsoftware.net On Jun 20, 2008, at 3:53 PM, j o a r wrote: On Jun 20, 2008, at 3:43 PM, Grant Limberg wrote: As far as I know, you can't store a raw jpeg in Core Data directly without turning it into an NSData object first which in turn decompresses it. It sounds quite possible that Core Data only support images in the form of NSData. That said, I see no reason why you would have to decompress the JPEG to generate this NSData. We need to know more about your application to provide more detailed assistance. Where do you get your JPEG images from? Over the network? From files in the file system? Pasted into an image view by the user? It sounds like you go from JPEG - NSImage - NSData? Instead of creating a NSImage, how about just storing the JPEG as is to the file system first, and only later generating NSImages as needed for display in your application. j o a r ___ 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: Creating a Bundle via Code
On Jun 20, 2008, at 4:00 PM, Grant Limberg wrote: Currently, the user drags an existing image from their filesystem to an NSImageView bound to an NSData attribute in the sqlite data store. This causes the decompression from 1.5MB to 20MB. As you can see, this isn't exactly efficient. Hence the question on package/bundle creation. I'm wanting to just store the jpeg directly to disk and just store a URL to it in the sqlite data store. You can always re-compress the image file before writing it out to the file system. But that seems kind of silly... I would suggest that you intercept the drag operation and copy the file directly. You should be able to do this quite easily if you subclass the image view: http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html j o a r ___ 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: Creating a Bundle via Code
On 20 Jun '08, at 4:00 PM, Grant Limberg wrote: Currently, the user drags an existing image from their filesystem to an NSImageView bound to an NSData attribute in the sqlite data store. This causes the decompression from 1.5MB to 20MB. That's an issue with NSImageView — when an image is dragged into it, it converts it into an NSImage (in most cases, an uncompressed pixmap). It does not store the original image data at all. So the binding has no alternative but to convert from the NSImage back into data. I would guess it uses TIFF for that. PNG would give somewhat better compression, but it won't be close to JPEG. (But it would be a bad idea for it to use JPEG, because that would decrease image quality and eliminate the alpha channel.) If you want to use an NSImageView but keep the original image data, you'll need to subclass it. I've done this once before. Basically you need to override the drag-and-drop methods and handle the drag yourself. At the end of the drag you convert the data into an NSImage and put that into the view, but you hang onto the data itself in the form of an NSData* instance variable. You can then write that data into the CoreData store. —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]