Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yiutsunchan

macrumors newbie
Original poster
Jul 15, 2008
6
0
Hello All of u

I am newbie in objective-c programming and I going to build a SQLite database by using XCode.

I had a NSMutableArray object which contain many instances in it as the picture showed.
Picture%203.png


I would like to build the SQLite database by using this NSMutableArray.

Can anyone give me some hints or sample code???
THX a lot~~~~~~~~
 

masonmey

macrumors newbie
Jul 15, 2008
8
0
Let me give a shot at pointing you in the right direction. Believe it or not, you could probably build this app without a single line of code (at least in a basic form). You want to use Core Data but it is going to involve a bit of work in Interface Builder. Check out this tutorial, http://www.cocoadevcentral.com/articles/000085.php. If you get stuck, hit me back and I will post some code for you.
 

yiutsunchan

macrumors newbie
Original poster
Jul 15, 2008
6
0
thank you for ur kindly reply~~~

But I would know if I have already build the model class file "restaurant" ,Is it possible to shift to core data method???

THX a lot

My model class file:
Code:
#import <Foundation/Foundation.h>

@interface Shop : NSObject {
	int shopID;
	NSString *shopName;
	NSString *shopTele;

}

@property (readwrite,nonatomic) int shopID;
@property (readwrite,copy,nonatomic) NSString *shopName;
@property (readwrite,copy) NSString *shopTele;

@end
 

masonmey

macrumors newbie
Jul 15, 2008
8
0
Yes, you can use your model class but you will have to make a few modifications. First, there are very good reasons to move to Core Data: you won't need to write any code to communicate with the database and you don't always need to create the model class. Anyway....here is what you need to do to move to that core data model.

- Start a project with the Core Data Application template (you can always copy over your other files)
- Open the .xcdata file in xcode (this is where you make the model of your object)
- In the Entity table, make your Shop entity and add your properties to it (you can learn more about that in that tutorial I posted). Change the Class column to use your "Shop" object (the file that you currently have).
- Finally, drag your files into xcode and in your Shop.h file...change NSObject to NSManagedObject. You also have to add #import <CoreData/CoreData.h>.

That might be a little confusing. Let me know if you need more help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.