OK, if you want to do a select statement that takes all the relevant data for a student, check out one or both of these guides. They're not the most current but the have what you need:
http://www.raywenderlich.com/913/sqlite-tutorial-for-ios-making-our-app
This example starts off with a FailedBankInfo
object, which would match up with your Student
. Note that they have the following method to create one of these objects using the values from the database:
- (id)initWithUniqueId:(int)uniqueId name:(NSString *)name city:(NSString *)city
state:(NSString *)state
The tutorial shows you how to get those values and to loop through the results.
Here's a second tutorial:
In this one, the example at the start is an Animal
object. A number of Animal
s are created from values in the database, similar to your Student
. The Animal
class looks like this:
@interface Animal : NSObject {
NSString *name;
NSString *description;
NSString *imageURL;
}
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *description;
@property (nonatomic, retain) NSString *imageURL;
-(id)initWithName:(NSString *)n description:(NSString *)d url:(NSString *)u;
@end
Those tutorials should get you going.
For additional information, @square was suggesting the following...
If you can rely on the sequence of the values in the three arrays, and by that I mean, if the values at index 3 in each of the arrays corresponds to the same student, you could do the following:
for (int i = 0; i < nameArray.count; i++) {
Student* student = [[Student alloc] initWithName:nameArray[i] number:numberArray[i] mark:markArray[i]];
[theStudents addObject:student];
}
The above relies on you having a class called Student
with an init
taking name, number and mark. And a mutable array called theStudents
.