Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-15-2011, 07:47 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 26
richammond is on a distinguished road
Default Unserialize functionality in ios??

Hi guys, i'm sure you all know the unserialze() function in PHP. I need the same thing for IOS. Basically i got a string from db field which looks like this :
a:4:{i:0;s:6:"Vincent";i:1;s:14:"Julie";i:2;s:12:" Tomas";i:3;s:10:"John";}

I would like the correct function to display the above string as : Vincent, Julie, Tomas, John.

I've looked into ios - Objective C: How to extract part of a String (e.g. start with '#') - Stack Overflow but didn't work out exactly as i wanted it :-(

Any help would be greatly appreciated.

Thanks!!
richammond is offline   Reply With Quote
Old 08-16-2011, 05:08 AM   #2 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 26
richammond is on a distinguished road
Default Re :

Anyone??
richammond is offline   Reply With Quote
Old 08-16-2011, 05:44 AM   #3 (permalink)
el guaje
 
kevinyide's Avatar
 
Join Date: Jun 2010
Posts: 243
kevinyide is on a distinguished road
Send a message via Yahoo to kevinyide
Default

Not sure if there is a correct function but you may want to take a look at this post.

Hope this helps.
kevinyide is offline   Reply With Quote
Old 08-16-2011, 07:16 AM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by richammond View Post
Hi guys, i'm sure you all know the unserialze() function in PHP. I need the same thing for IOS. Basically i got a string from db field which looks like this :
a:4:{i:0;s:6:"Vincent";i:1;s:14:"Julie";i:2;s:12:" Tomas";i:3;s:10:"John";}

I would like the correct function to display the above string as : Vincent, Julie, Tomas, John.

I've looked into ios - Objective C: How to extract part of a String (e.g. start with '#') - Stack Overflow but didn't work out exactly as i wanted it :-(

Any help would be greatly appreciated.

Thanks!!
No, I don't know the PHP unserialze (unserialize?) command.

In general terms, it looks like a command that takes a variable (or object) and converts it to a byte-stream. That concept exists in Cocoa as well. However, the details are different. I doubt you'll find a ready-made way to unserialize PHP variables/objects into Objective C, since they are different languages, and their data structures and constructs are different. PHP is loosely typed, for example, which is likely to cause problems in creating Objective C equivalent structures.

You'll probably have to restrict what you put the DB fields in PHP to a specific format (or small set of possible formats), and then write Objective C code that parses that specific format into Objective C data containers.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 08-18-2011, 05:14 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 26
richammond is on a distinguished road
Default Re

Thanks!! Guess what i've done is as suggested : make sure the data being serialised is in a readable format. I wanted to go the quickest route, but seems like that one was the longest but simpler!!

Thanks again
richammond is offline   Reply With Quote
Old 08-18-2011, 07:52 AM   #6 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by richammond View Post
Thanks!! Guess what i've done is as suggested : make sure the data being serialised is in a readable format. I wanted to go the quickest route, but seems like that one was the longest but simpler!!

Thanks again
It will probably be easier to export the data in a format like JSON that is cross-platform.

You could also use a PHP implementation of property lists, like CFPropertyList

Binary property lists are a whole lot faster and more efficient than text-based formats like JSON (or worse yet XML)
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.

Last edited by Duncan C; 08-18-2011 at 07:55 AM.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

Tags
array, characters, ios, string, unserialize

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 393
13 members and 380 guests
7twenty7, chiataytuday, cristofercolmbos, dedeys78, dre, fiftysixty, gmarro, jimmyon122, jonathandeknudt, pungs, raymng, tymex, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:08 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0