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 06-08-2011, 11:38 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 5
alphaJA is on a distinguished road
Default Beginner - How to fetch data from websites.

Hello all,

First off, I am new to this forum, and I am excited to be a part of this community!
Although I have been programming for about 3 years(in an academic setting), I am new to the iPhone platform as well as the concept of working on my personal projects(All I've done so far in my life is school projects).
I have taken a Data Structures and an Algorithms course at my University, so I believe I have the very basics of programming down.

To get used to the iPhone platform, I am trying to make a Random Band Name Generator that fetches the words from websites.
For starters, I already made version 1, which generates a random name based on the 10 nouns and adjectives that I chose. I basically have two NSArrays(adjectiveArray and nounArray).
This one was fairly easy, and it's working fine.

So here's my question:

I want to fetch a random word from say dictionary.com. How do I go about doing that?

Thanks peop!
alphaJA is offline   Reply With Quote
Old 06-08-2011, 02:01 PM   #2 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 389
Esko2300 is on a distinguished road
Default

Well in order to do that you can use there api they developed for programmers to use(i believe its free for you to develop with , but if you want to use their services in a app you plan to sell then you must pay for it). Just go to dictionary.com and you can find it there. I never used it before so i dont know its capabilities but in my opinion thats a good place to start.
Esko2300 is offline   Reply With Quote
Old 06-08-2011, 02:03 PM   #3 (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 alphaJA View Post
Hello all,

First off, I am new to this forum, and I am excited to be a part of this community!
Although I have been programming for about 3 years(in an academic setting), I am new to the iPhone platform as well as the concept of working on my personal projects(All I've done so far in my life is school projects).
I have taken a Data Structures and an Algorithms course at my University, so I believe I have the very basics of programming down.

To get used to the iPhone platform, I am trying to make a Random Band Name Generator that fetches the words from websites.
For starters, I already made version 1, which generates a random name based on the 10 nouns and adjectives that I chose. I basically have two NSArrays(adjectiveArray and nounArray).
This one was fairly easy, and it's working fine.

So here's my question:

I want to fetch a random word from say dictionary.com. How do I go about doing that?

Thanks peop!
You need support from the server to do what you are asking for. It might be easier to get a list of words and store it locally. I have a link to a tutorial in my signature that generates random passwords using pairs of words from a public domain word list I found online. The word list I found contained over 100,000 English words.

In my app, I do a one-time conversion where I convert a text-based list of words to a plist, which is a Cocoa structured file that is easy to read into a Cocoa NSArray. I run that step once and then install the plist file into the app. The code that does the text file to plist file conversion is in the project. It might need to be modified somewhat depending on the format of the word list file you find. (The file I found used carriage return/linefeed to terminate each line, which is a Windows convention. Files for Mac/Unix use different line terminators)

After conversion, my 100,000+ word file is only about 1.9 megabytes long, which is fairly small by today's standards, and would be no problem to embed in an iOS app.

If you're determined to get a random word from an online dictionary, you would need an API from the server. It might be something as simple as sending a specially formatted URL - something like this:

PHP Code:
http://www.dictionaryserver.com/randomnoun.php 
or

PHP Code:
http://www.dictionaryserver.com/randomadjective.php 
That would trigger a PHP script on the server which would generate a random word of the requested type and return it.

You could then use the call stringWithContentsOfURL:encoding:error: to send that URL to the server and capture the results into a string object. However, you would need somebody to set up a server with your word list, and write the php scripts to do that.

It sounds like you need two separate lists: nouns and adjectives. You'd have to search around on the 'net for such lists, but I bet you could find them. My random password generator project contains a lot of the code you would need.
__________________
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 06-17-2011, 02:20 AM   #4 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 5
alphaJA is on a distinguished road
Default

Thanks for the replies.
I think I'll just try locally storing a public domain word list, like you said.
Thanks for the help
alphaJA is offline   Reply With Quote
Reply

Bookmarks

Tags
beginner, generator, random

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: 327
7 members and 320 guests
chemistry, Dnnake, iOS.Lover, jenniead38, lendo, pbart, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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