Sam
Sam

Reputation: 31

How Do I expose CFPropertyList for IPhone application from CodeIgniter

Is there any possibility to expose CFPropertyList for IPhone application from CodeIgniter website. I googled the examples and tutorials but I did not find any relevant information.

Simply I want to do the following.

  1. I will call a URL from my Iphone application of the Codeigniter website by passing some query strings

  2. and my php page will fetch the data from my MySql database.

  3. finally it would echo the result in Plist for Iphone application

Thanks for your help!!

Upvotes: 0

Views: 486

Answers (2)

Peter Drinnan
Peter Drinnan

Reputation: 4533

I use CFPropertyList all the time in my CI apps. The trick is to not use the CI library load method.It will always throw an error because CodeIgniter does not yet support Namespaces (likely why so many people are moving to Laravel), and the CFPropertyList library uses Namespaces.

Here is a example showing how to use CFPropertyList within a CI function:

public function getRecord($id){

    require_once(__DIR__.'/../libraries/CFPropertyList/CFPropertyList.php');

    $plistfile = ASSET_ROOT . 'uploads/fashion/FasionItems.plist';
    $content = file_get_contents($plistfile);

    /* notice use of the \ character */
    $plist = new CFPropertyList\CFPropertyList();

    $plist->parse($content);
    $plistarray = $plist->toArray();


    foreach($plistarray['Episodes'] AS $key => $record){

        if($record['ItemId'] == $id){  

            return $record;
            break;

        }

    }

    return FALSE;

}

Upvotes: 1

Johann du Toit
Johann du Toit

Reputation: 2667

Maybe this can help:

The PHP implementation of Apple's PropertyList can handle XML PropertyLists as well as binary PropertyLists. It offers functionality to easily convert data between worlds, e.g. recalculating timestamps from unix epoch to apple epoch and vice versa. A feature to automagically create (guess) the plist structure from a normal PHP data structure will help you dump your data to plist in no time.

https://github.com/rodneyrehm/CFPropertyList

I Haven't actually used this.

Upvotes: 1

Related Questions