PDA

View Full Version : Tableview input from server




Bennie98
Jan 6, 2011, 08:54 AM
Hi
I'm trying to input an array into the tableview. Coming from a serverfile.

How do I do this? Which fileformats are possible in which the array is put? like: xml, json, (m3u8 if that's possible), other...?

And if you want to select a file from the tableview (videofile title) to play in MPMoviePlayer, how do you go and handle this?

I've succeeded to put a regular array in a tableview but an input from a serverfile would be much handier than a local file...

If anyone got an answer on one of these questions, I would much appreciate it if they could help.
(I've looked on the internet and in books but I can't seem to find it anywhere :/ )

Best Regards

Bennie98



robbieduncan
Jan 6, 2011, 09:04 AM
Your questions are overly vague.

For example you can load any file format you want into an NSArray as long as you are willing to parse the contents of the file yourself and turn the contents into valid objects. If you mean "what formats can I use with initWithContentsOfFile" then the answer is, as described in the documentation (http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/occ/instm/NSArray/initWithContentsOfFile:), plist only.

Bennie98
Jan 6, 2011, 09:17 AM
since I'm pretty much a newbie on macscripting I have no idea..

I presume it's got to do with "- (id)initWithContentsOfURL:(NSURL *)aURL"
maybe not.. maybe it' s like you said with the "initWithContentsOfFile"

I'm unbelievably lost in this subject :/.
I just want a variable file loaded in the tableview from my server.

imagine it's an xml file which contains


<table of content>
<item1="....">
<item2="....">
</table of content>


and I want the 2 items or more in my tableview.
how can I manage this?
what would you recommend?

what are my possibility's?

grts

robbieduncan
Jan 6, 2011, 09:20 AM
I would recommend you take about 10 steps back. You are not thinking like a programmer which would lead me to believe you haven't bothered to learn to program, rather have copy & pasted some example code without understanding what you are doing.

You need to break the problem down into a series of every smaller problems until you reach problems that can be solved. There is no one-line solution to this: you need to parse the input, convert that to objects and then connect that data model up to the table view.

Bennie98
Jan 6, 2011, 09:28 AM
I must admit, I don't think like a programmer yet.
Because I'm used to program in AS and C not objective C..
I don't understand practical things about xcode and interface builder...
I've got some things to work.. and I'm studying this on my own, with books and tutorials online...
But it doesn't seem to be enough...
I've learned from several books the very basics but since they are all in english and not in dutch it's sometimes hard to understand some quite basic and necessary things... It frustrates me very much...

dejo
Jan 6, 2011, 10:06 AM
...but since they are all in english and not in dutch it's sometimes hard to understand some quite basic and necessary things... It frustrates me very much...
I believe there are a few other members active in this forum from The Netherlands. Reach out to them and perhaps they can help you.

My parents were Dutch but unfortunately my grasp of the language is not nearly good enough to hold a conversation on technical topics, begrijpt u dat?

I hate to admit it but English is the de-facto language of iOS Programming, at least, probably programming, in general. Most resources are tailored to English speakers. You probably will need to become more comfortable with English if you wish to pursue this long-term. Not what you wanted to hear, I bet, but those are the facts, as I see them.

Bennie98
Jan 6, 2011, 10:16 AM
Yes ik begrijp dat :)

I have a pretty good grasp on the english language... The only problem is that there is a very specific terminology surrounding programming. So that's my biggest issue.

And I really don't want to bother anyone over the internet... I'm a very though student... I ask very hard questions even for a licensed tutor...
So it won't work via the internet...

There is one book about iphone/ipad programming in dutch. But they left out the part about classes... and that's a part i really need to learn in dutch.. the connections with the other parts of the xcode project and so on....

So as long as I do not find a book in dutch I'm afraid I won't advance.. :/
unless maybe if I practice enough... practically.. but doing so is not easy when you don't have the basics in your head....

robbieduncan
Jan 6, 2011, 10:25 AM
Well, if you do succeed in learning you could always write a better book in Dutch...

Bennie98
Jan 7, 2011, 02:28 AM
Lol,
yes thanks I will try that..
Yesterday, the bookstore finally sent me a mail saying that my book that I ordered was in.

Beginning iPad Application Development by Wei Meng Lee

I sure hope this gives me what I need....

best regards

Bennie98

dejo
Jan 7, 2011, 09:03 AM
Let us know how that book turns out.

Bennie98
Jan 11, 2011, 05:10 AM
I've been looking up some things about how to populate table views.
For the moment I've found that you can use XML files and plist files.

So just for the record... these are the only ones? or are there any others which I can use...

I know I'm not yet a fully trained programmer.. but I'm sure I'm not asking an impossible question here...

I just want to know which filetypes I can use.. I do not yet need to know how to implement them or anything... just want to know which ones I can use...

In the meanwhile I'm studying in the book I got. Helped me out quite a bit already. Getting to know the syntax and underlying connections. :) really handy

robbieduncan
Jan 11, 2011, 05:13 AM
You are thinking about this the wrong way. No filetype can be used directly, without intermediate code, to supply data to a UITableView. plist files, whether in xml or binary format, can be directly loaded as a NSArray or NSDictionary which makes the intermediate code you have to write to supply data to the table view easy. Other file formats you would have to parse yourself or find a parser you could integrate into your application. This is harder (but certainly not impossible).

Bennie98
Jan 11, 2011, 06:03 AM
thx for the answer... I had already gotten that from the first comment you gave.
I just didn't know I could use other types too.
Anyways thx for the feedback

grtz

Bennie98

dejo
Jan 11, 2011, 09:43 AM
As robbieduncan is saying, you can pretty much use whatever file type you want. The possibilities are nearly unlimited. The trick is in understanding the format of the file enough to be able to write code to parse the desired information out of it. For example, a properly-formatted text file, where every line in the file will be a row in the table, would be fairly simple to parse into an array to become the data source for your table. For another example, you could use an Excel spreadsheet, where every row in the spreadsheet backs a row in the table, but parsing a file of this type would be harder. And so on...