Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 20.4 ('Xojo Jigsaw')
Instant purchase and download via GumRoad!

FEATURE

Bundle It

Save your document as a MacOS Package

Issue: 20.4 (July/August 2022)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 14,343
Starting Page Number: 26
Article Number: 20403
Resource File(s):

Download Icon project20403.zip Updated: 2022-06-30 18:36:07

Related Link(s): None

Excerpt of article text...

Bundles are cool. They're basically a collection of files inside a folder that appear to be a single file to the user. Mac applications are bundles, for instance, and can include executable code, pictures, text, data, fonts, and other kinds of resources. But to the user, it's just a single application file.

You can also use the same bundle concept as a document format. Say you've written a program that saves a document that contains multiple pieces of text and pictures. You really want the user to see only a single file, not a bunch of text and picture files. You could store everything in an XML file, with the pictures encoded as binary data, but that's complicated and a hassle. It's also not too user-friendly as XML isn't very human-readable. A better approach is to save the document as a bundle (more accurately called a package as Apple thinks bundles contain code: see https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html). Inside the bundle are separate files for each text and photo, but the user sees just a single file.

Unfortunately, bundles/packages are an Apple thing, so they're only available on MacOS and iOS. If your project needs to be cross-platform and you want the same concept, you'd probably need to use a .zip file archive (which can contain multiple files inside it). Reading and saving .zip files is complex, though, requiring a plugin or extra code, and not necessary if your project is going to be Mac- or iOS-only.

Creating a Bundle

So how do you go about creating a bundle? Years ago I had to do it with a special system call. That method broke with operating system upgrades as Apple depreciated that way of doing things.

Now bundles are basically created automatically by the system—if you set things up just right.

...End of Excerpt. Please purchase the magazine to read the full article.