 |
 |
|
 |
11-06-2008, 05:31 PM
|
#1 (permalink)
|
|
New Member
Join Date: Nov 2008
Posts: 4
|
A Loop to load data
To load 10 records and be able to use them later I load them one by one (please don't laugh, i'm a beginner). Can someone show me how to write a loop
DataBaseSQLiteAppDelegate *appDelegate = (DataBaseSQLiteAppDelegate *)[[UIApplication sharedApplication] delegate];
Data *datax = (Data *)[appDelegate.dataInformation objectAtIndex:indexPath.row];
Data *datax0 = (Data *)[appDelegate.dataInformation objectAtIndex:0];
Data *datax1 = (Data *)[appDelegate.dataInformation objectAtIndex:1];
Data *datax2 = (Data *)[appDelegate.dataInformation objectAtIndex:2];
Data *datax3 = (Data *)[appDelegate.dataInformation objectAtIndex:3];
Data *datax4 = (Data *)[appDelegate.dataInformation objectAtIndex:4];
Data *datax5 = (Data *)[appDelegate.dataInformation objectAtIndex:5];
Data *datax6 = (Data *)[appDelegate.dataInformation objectAtIndex:6];
Data *datax7 = (Data *)[appDelegate.dataInformation objectAtIndex:7];
Data *datax8 = (Data *)[appDelegate.dataInformation objectAtIndex:8];
Data *datax9 = (Data *)[appDelegate.dataInformation objectAtIndex:9];
listContent = [[NSMutableArray alloc] initWithObjects:datax0.contact, datax1.contact, datax2.contact, datax3.contact, datax4.contact,
datax5.contact, datax6.contact, datax7.contact, datax8.contact, datax9.contact, nil];
cell.text = [filteredListContent objectAtIndex:indexPath.row];
|
|
|
11-06-2008, 05:39 PM
|
#2 (permalink)
|
|
New Member
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
|
Code:
NSMutableArray *listContent = [[NSMutableArray alloc] init];
for (int i = 0; i < 10; i++) {
Data *data = (Data *)[appDelegate.dataInformation objectAtIndex:i];
[listContent addObject:data];
}
|
|
|
11-06-2008, 11:27 PM
|
#3 (permalink)
|
|
New Member
Join Date: Oct 2008
Posts: 14
|
Does it work for values other than 10?
|
|
|
11-07-2008, 12:20 AM
|
#4 (permalink)
|
|
New Member
Join Date: Apr 2008
Posts: 802
|
Just change the 10 to something else. You really should consider at least downloading the free Intro to Objective-C at Apple's site. Loops are very basic to programming.
|
|
|
11-07-2008, 12:33 AM
|
#5 (permalink)
|
|
New Member
Join Date: Oct 2008
Posts: 14
|
Sorry it was sarcasm. I do believe that posts like these should not be answered. At least not in this manner. There are more and more completely clueless users asking very basic questions on these forums, drowning the few interesting subjects with questions that have either been answered over and over again, or especially now demonstrate a total lack of ability to read even the simplest of documents or procedures or even the most basic programming knowledge.
Understand me, I welcome all new users to the community, and the more of us the better, but I do feel that it is everybody's duty to observe a minimum of patience before posting any question, and understanding than instead of getting things done by other people it will be
- faster
- more effective
- the ONLY way
to read and experiment and understand the documentation.
Basically, if you can't write a loop, there is no amount of posting to these forums, however detailed the answers, that will make you ever get something accomplished. You have to absorb a minimal set of information by yourself or eveyr single step of your development will be a road block. Through that kind of trial and error it would take years to get a GUI hello world done.
If you don't know where to start, type "objective-c" and "cocoa iphone tutorial" in google.
I am open to criticism if this reply is seen as elitist, though I would like to believ that it would be salvatory instead of perpetuating the idea that you can get things done by asking questions to the community when you encounter a problem. It should ALWAYS be a last resort, not even not to distrurb said community, but because it will be 1000 times more efficient to
1. read and assimilate various amount of documenttion while looking for an answer
2. learn to solve problems by yourself.
3. Google is your friend for 99% left unanswered - developping good search skills and several sources of information is crucial. It will always be faster than wait for an answer from a human on the forums, especially since the more general the question (thus when it hasnt been researched) the less useful the answer in actual code terms (sure now you can use a loop, but you still don't know when to use one, what iterators are, when to use a while, how to write an inverse loop, how to break in special cases, etc... all of which would take you 5 minutes to find out if you typed "obective-c loop syntax in google" and read the first 5 links, discard the 2 worst, bookmark the best one, read, understand, assimilate, learn, rinse, repeat...)
Last edited by Alex.be; 11-07-2008 at 12:40 AM.
|
|
|
11-07-2008, 07:23 AM
|
#6 (permalink)
|
|
Registered Member
Join Date: Oct 2008
Posts: 486
|
Alex.be you are absolutely correct. I may be a new poster here (long time lurker) but it blows me away the number of "plz u can writ mai prg 4 mee?" type posts there are. Not the OP in this case, at least he learned how to load the data he needed in by himself, just not the most efficiently. I'm still new to the Objective C language, but have been learning a lot from the knowledgeable posters by lurking and reading PDFs and tutorials- not by asking questions.
Somehow everybody and their brother found the download link to the SDK but missed the 10 tons of sample programs, video and PDF guides right below it in the iPhone Dev Center!
My favorite one this week was in another forum (Macrumors I think) where someone was asking if the SDK was a GUI editor that built your code and app for you, point and click like "Frontpage".
Hopefully, with a bunch of sweat and reading the docs my first app will make it in the store by the end of the year. I went a bit ambitious for my first time out and started in with a game immediately. But that's only because I had previous programming and art background. *lurks more*
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 547 |
| 44 members and 503 guests |
| AptoTech, Avalanchis, byDecker, carminati, CHV, develsolutions, dre, Duncan C, embedded, flamingliquid, freedoom, GoNXaS, gshaviv, hatembr, headkaze, HemiMG, hstaniloff, iTrackiGiveaway, jackeveritt, JaredJohnson325, jmonroe, Julie, jyu, listingboat, mistergod, MrMattMac, myPhone, NixS, prophox, Raazo, rocketman240, Rudy, ryguy2503, sayer, seilinho, shweta13, SimonHodgkiss, soga, TapThatApp, toughturtle, warmi, whale88 |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,185
Threads: 38,957
Posts: 170,914
Top Poster: smasher (2,565)
|
| Welcome to our newest member, JaredJohnson325 |
|