Appcelerator Blog

The Leading Resource for All Things Mobile

Changes to filesystem on iOS

0 Flares 0 Flares ×

With the release of Titanium 1.7.0, there have been some changes put in place on iOS to help with relative and absolute path resolution for files on device, and to allow better cross-platform development by interpreting paths and providing directory information the same way that Titanium on Android does.

Previously, file operations on iOS were performed only on paths, which were used interchangably with file URIs. There was always some confusion about where exactly a “relative” path was relative to, and whether absolute paths should be measured from the root of the filesystem (which developers generally do not have access to) or from some other location that makes more sense for your application. Now, there are some consistent guidelines for filesystem use on iOS:

  • Relative paths are now considered to be relative to the javascript file they are being executed from.
  • Absolute paths are now considered to be relative to the application resources directory (i.e. the same directory where your app.js is stored).
  • All other paths – including those returned by Titanium.Filesystem properties – are now file URIs. For example, Titanium.Filesystem.resourcesDirectory is now a file URI pointing to the resources directory of the application (where the app.js is stored) – including a trailing slash.

For example:

Will log what you’d hope it would (‘X is: Hello!’) to the console.

For those of you writing custom modules which take advantage of the filesystem, to conform to these new guidelines, you will need to make sure that you handle paths in a manner consistent with Titanium. We provide two internal methods in our source which you can use for this: +[TiUtils toURL:proxy:] and +[TiUtiuls toURL:relativeToURL:]. These translate string paths to NSURL objects, which can then have their filesystem path component extracted.

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×

Sign up for updates!

Become a mobile leader. Take the first step to scale mobile innovation throughout your enterprise.
Get in touch
computer and tablet showing Appcelerator software
Start free, grow from there.
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×