亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 系統 > iOS > 正文

以代碼實例總結iOS應用開發中數據的存儲方式

2020-07-26 03:27:23
字體:
來源:轉載
供稿:網友

ios數據存儲包括以下幾種存儲機制:

  • 屬性列表
  • 對象歸檔
  • SQLite3
  • CoreData
  • AppSettings
  • 普通文件存儲

1、屬性列表

復制代碼 代碼如下:

// 
//  Persistence1ViewController.h 
//  Persistence1 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import <UIKit/UIKit.h> 
#define kFilename @"data.plist" 
 
@interface Persistence1ViewController : UIViewController { 
    UITextField *filed1; 
    UITextField *field2; 
    UITextField *field3; 
    UITextField *field4; 

@property (nonatomic, retain) IBOutlet UITextField *field1; 
@property (nonatomic, retain) IBOutlet UITextField *field2; 
@property (nonatomic, retain) IBOutlet UITextField *field3; 
@property (nonatomic, retain) IBOutlet UITextField *field4; 
 
- (NSString *)dataFilePath; 
- (void)applicationWillResignActive:(NSNotification *)notification; 
 
@end 

復制代碼 代碼如下:

// 
//  Persistence1ViewController.m 
//  Persistence1 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import "Persistence1ViewController.h" 
 
@implementation Persistence1ViewController 
@synthesize field1; 
@synthesize field2; 
@synthesize field3; 
@synthesize field4; 
 
//數據文件的完整路徑 
- (NSString *)dataFilePath { 
    //檢索Documents目錄路徑。第二個參數表示將搜索限制在我們的應用程序沙盒中 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    //每個應用程序只有一個Documents目錄 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    //創建文件名 
    return [documentsDirectory stringByAppendingPathComponent:kFilename]; 

 
//應用程序退出時,將數據保存到屬性列表文件 
- (void)applicationWillResignActive:(NSNotification *)notification { 
    NSMutableArray *array = [[NSMutableArray alloc] init]; 
    [array addObject: field1.text]; 
    [array addObject: field2.text]; 
    [array addObject: field3.text]; 
    [array addObject: field4.text]; 
    [array writeToFile:[self dataFilePath] atomically:YES]; 
    [array release]; 

 
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
*/ 
 
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/ 
 
 
 
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSString *filePath = [self dataFilePath]; 
    //檢查數據文件是否存在 
    if([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { 
        NSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath]; 
        field1.text = [array objectAtIndex:0]; 
        field2.text = [array objectAtIndex:1]; 
        field3.text = [array objectAtIndex:2]; 
        field4.text = [array objectAtIndex:3]; 
        [array release]; 
    } 
    UIApplication *app = [UIApplication sharedApplication]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                            selector:@selector(applicationWillResignActive:) 
                                            name:UIApplicationWillResignActiveNotification 
                                            object:app]; 
    [super viewDidLoad]; 

 
 
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/ 
 
- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 
     
    // Release any cached data, images, etc that aren't in use. 

 
- (void)viewDidUnload { 
    self.field1 = nil; 
    self.field2 = nil; 
    self.field3 = nil; 
    self.field4 = nil; 
    [super viewDidUnload]; 

 
 
- (void)dealloc { 
    [field1 release]; 
    [field2 release]; 
    [field3 release]; 
    [field4 release]; 
    [super dealloc]; 

 
@end 

2、對象歸檔

復制代碼 代碼如下:

// 
//  Fourlines.h 
//  Persistence2 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import <Foundation/Foundation.h> 
 
@interface Fourlines : NSObject <NSCoding, NSCopying> { 
    NSString *field1; 
    NSString *field2; 
    NSString *field3; 
    NSString *field4; 

@property (nonatomic, retain) NSString *field1; 
@property (nonatomic, retain) NSString *field2; 
@property (nonatomic, retain) NSString *field3; 
@property (nonatomic, retain) NSString *field4; 
 

@end 


復制代碼 代碼如下:

// 
//  Fourlines.m 
//  Persistence2 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import "Fourlines.h" 
 
#define kField1Key @"Field1" 
#define kField2Key @"Field2" 
#define kField3Key @"Field3" 
#define kField4Key @"Field4" 
 
@implementation Fourlines 
@synthesize field1; 
@synthesize field2; 
@synthesize field3; 
@synthesize field4; 
 
#pragma mark NSCoding 
- (void)encodeWithCoder:(NSCoder *)aCoder { 
    [aCoder encodeObject:field1 forKey:kField1Key]; 
    [aCoder encodeObject:field2 forKey:kField2Key]; 
    [aCoder encodeObject:field3 forKey:kField3Key]; 
    [aCoder encodeObject:field4 forKey:kField4Key]; 

 
-(id) initWithCoder:(NSCoder *)aDecoder { 
    if(self = [super init]) { 
        field1 = [[aDecoder decodeObjectForKey:kField1Key] retain]; 
        field2 = [[aDecoder decodeObjectForKey:kField2Key] retain]; 
        field3 = [[aDecoder decodeObjectForKey:kField3Key] retain]; 
        field4 = [[aDecoder decodeObjectForKey:kField4Key] retain]; 
    } 
    return self; 

 
#pragma mark - 
#pragma mark NSCopying 
- (id) copyWithZone:(NSZone *)zone { 
    Fourlines *copy = [[[self class] allocWithZone: zone] init]; 
    copy.field1 = [[self.field1 copyWithZone: zone] autorelease]; 
    copy.field2 = [[self.field2 copyWithZone: zone] autorelease]; 
    copy.field3 = [[self.field3 copyWithZone: zone] autorelease]; 
    copy.field4 = [[self.field4 copyWithZone: zone] autorelease]; 
    return copy; 

@end 

復制代碼 代碼如下:

// 
//  Persistence2ViewController.h 
//  Persistence2 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import <UIKit/UIKit.h> 
#define kFilename @"archive" 
#define kDataKey @"Data" 
 
@interface Persistence2ViewController : UIViewController { 
    UITextField *filed1; 
    UITextField *field2; 
    UITextField *field3; 
    UITextField *field4; 

@property (nonatomic, retain) IBOutlet UITextField *field1; 
@property (nonatomic, retain) IBOutlet UITextField *field2; 
@property (nonatomic, retain) IBOutlet UITextField *field3; 
@property (nonatomic, retain) IBOutlet UITextField *field4; 
 
- (NSString *)dataFilePath; 
- (void)applicationWillResignActive:(NSNotification *)notification; 
 
@end 

復制代碼 代碼如下:

// 
//  Persistence2ViewController.m 
//  Persistence2 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import "Persistence2ViewController.h" 
#import "Fourlines.h" 
 
@implementation Persistence2ViewController 
@synthesize field1; 
@synthesize field2; 
@synthesize field3; 
@synthesize field4; 
 
//數據文件的完整路徑 
- (NSString *)dataFilePath { 
    //檢索Documents目錄路徑。第二個參數表示將搜索限制在我們的應用程序沙盒中 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    //每個應用程序只有一個Documents目錄 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    //創建文件名 
    return [documentsDirectory stringByAppendingPathComponent:kFilename]; 

 
//應用程序退出時,將數據保存到屬性列表文件 
- (void)applicationWillResignActive:(NSNotification *)notification { 
    Fourlines *fourlines = [[Fourlines alloc] init]; 
    fourlines.field1 = field1.text; 
    fourlines.field2 = field2.text; 
    fourlines.field3 = field3.text; 
    fourlines.field4 = field4.text; 
     
    NSMutableData *data = [[NSMutableData alloc] init];//用于存儲編碼的數據 
    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; 
     
    [archiver encodeObject:fourlines forKey:kDataKey]; 
    [archiver finishEncoding]; 
    [data writeToFile:[self dataFilePath] atomically:YES]; 
     
    [fourlines release]; 
    [archiver release]; 
    [data release]; 

 
/*
 // The designated initializer. Override to perform setup that is required before the view is loaded.
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
 if (self) {
 // Custom initialization
 }
 return self;
 }
 */ 
 
/*
 // Implement loadView to create a view hierarchy programmatically, without using a nib.
 - (void)loadView {
 }
 */ 
 
 
 
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSString *filePath = [self dataFilePath]; 
    //檢查數據文件是否存在 
    if([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { 
         
        //從文件獲取用于解碼的數據 
        NSData *data = [[NSMutableData alloc] initWithContentsOfFile:[self dataFilePath]]; 
        NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; 
         
        Fourlines *fourlines = [unarchiver decodeObjectForKey:kDataKey]; 
        [unarchiver finishDecoding]; 
         
        field1.text = fourlines.field1; 
        field2.text = fourlines.field2; 
        field3.text = fourlines.field3; 
        field4.text = fourlines.field4; 
         
        [unarchiver release]; 
        [data release]; 
    } 
    UIApplication *app = [UIApplication sharedApplication]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(applicationWillResignActive:) 
                                             name:UIApplicationWillResignActiveNotification 
                                             object:app]; 
    [super viewDidLoad]; 

 
 
/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */ 
 
- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 
     
    // Release any cached data, images, etc that aren't in use. 

 
- (void)viewDidUnload { 
    self.field1 = nil; 
    self.field2 = nil; 
    self.field3 = nil; 
    self.field4 = nil; 
    [super viewDidUnload]; 

 
 
- (void)dealloc { 
    [field1 release]; 
    [field2 release]; 
    [field3 release]; 
    [field4 release]; 
    [super dealloc]; 

@end 

3、SQLite

復制代碼 代碼如下:

// 
//  Persistence3ViewController.h 
//  Persistence3 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import <UIKit/UIKit.h> 
#define kFilename @"data.sqlite3" 
 
@interface Persistence3ViewController : UIViewController { 
    UITextField *filed1; 
    UITextField *field2; 
    UITextField *field3; 
    UITextField *field4; 

@property (nonatomic, retain) IBOutlet UITextField *field1; 
@property (nonatomic, retain) IBOutlet UITextField *field2; 
@property (nonatomic, retain) IBOutlet UITextField *field3; 
@property (nonatomic, retain) IBOutlet UITextField *field4; 
 
- (NSString *)dataFilePath; 
- (void)applicationWillResignActive:(NSNotification *)notification; 
@end 

復制代碼 代碼如下:

// 
//  Persistence3ViewController.m 
//  Persistence3 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import "Persistence3ViewController.h" 
#import <sqlite3.h> 
 
@implementation Persistence3ViewController 
@synthesize field1; 
@synthesize field2; 
@synthesize field3; 
@synthesize field4; 
 
//數據文件的完整路徑 
- (NSString *)dataFilePath { 
    //檢索Documents目錄路徑。第二個參數表示將搜索限制在我們的應用程序沙盒中 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    //每個應用程序只有一個Documents目錄 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    //創建文件名 
    return [documentsDirectory stringByAppendingPathComponent:kFilename]; 

 
//應用程序退出時,將數據保存到屬性列表文件 
- (void)applicationWillResignActive:(NSNotification *)notification { 
    sqlite3 *database; 
    if(sqlite3_open([[self dataFilePath] UTF8String], &database) != SQLITE_OK) { 
        sqlite3_close(database); 
        NSAssert(0, @"Failed to open database"); 
    } 
     
    for(int i = 1; i <= 4; i++) { 
        NSString *fieldname = [[NSString alloc] initWithFormat:@"field%d", i]; 
        UITextField *field = [self valueForKey:fieldname]; 
        [fieldname release]; 
         
        char *update = "INSERT OR REPLACE INTO FIELDS (ROW, FIELD_DATA) VALUES (?, ?);"; 
        sqlite3_stmt *stmt; 
        //將SQL語句編譯為sqlite內部一個結構體(sqlite3_stmt),類似java JDBC的PreparedStatement預編譯 
        if (sqlite3_prepare_v2(database, update, -1, &stmt, nil) == SQLITE_OK) { 
            //在bind參數的時候,參數列表的index從1開始,而取出數據的時候,列的index是從0開始 
            sqlite3_bind_int(stmt, 1, i); 
            sqlite3_bind_text(stmt, 2, [field.text UTF8String], -1, NULL); 
        } else { 
            NSAssert(0, @"Error:Failed to prepare statemen"); 
        } 
        //執行SQL文,獲取結果  
        int result = sqlite3_step(stmt); 
        if(result != SQLITE_DONE) { 
            NSAssert1(0, @"Error updating table: %d", result); 
        } 
        //釋放stmt占用的內存(sqlite3_prepare_v2()分配的) 
        sqlite3_finalize(stmt); 
    } 
    sqlite3_close(database); 

 
/*
 // The designated initializer. Override to perform setup that is required before the view is loaded.
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
 if (self) {
 // Custom initialization
 }
 return self;
 }
 */ 
 
/*
 // Implement loadView to create a view hierarchy programmatically, without using a nib.
 - (void)loadView {
 }
 */ 
 
 
 
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSString *filePath = [self dataFilePath]; 
    //檢查數據文件是否存在 
    if([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { 
        //打開數據庫 
        sqlite3 *database; 
        if(sqlite3_open([filePath UTF8String], &database) != SQLITE_OK) { 
            sqlite3_close(database); 
            NSAssert(0, @"Failed to open database"); 
        } 
         
        //創建表 
        char *errorMsg; 
        NSString *createSQL =  
            @"CREATE TABLE IF NOT EXISTS FIELDS (ROW INTEGER PRIMARY KEY, FIELD_DATA TEXT);"; 
        if(sqlite3_exec(database, [createSQL UTF8String], NULL, NULL, &errorMsg) != SQLITE_OK) { 
            sqlite3_close(database); 
            NSAssert(0, @"Error creating table: %s", errorMsg); 
        } 
 
        //查詢 
        NSString *query = @"SELECT ROW, FIELD_DATA FROM FIELDS ORDER BY ROW"; 
        sqlite3_stmt *statement; 
        //設置nByte可以加速操作 
        if(sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) { 
            while (sqlite3_step(statement) == SQLITE_ROW) {//返回每一行 
                int row = sqlite3_column_int(statement, 0); 
                char *rowData = (char *)sqlite3_column_text(statement, 1); 
                 
                NSString *fieldName = [[NSString alloc] initWithFormat:@"field%d", row]; 
                NSString *fieldValue = [[NSString alloc] initWithUTF8String:rowData]; 
                 
                UITextField *field = [self valueForKey:fieldName]; 
                field.text = fieldValue; 
                 
                [fieldName release]; 
                [fieldValue release]; 
            } 
            //釋放statement占用的內存(sqlite3_prepare()分配的) 
            sqlite3_finalize(statement); 
        } 
        sqlite3_close(database); 
    } 
     
     
    UIApplication *app = [UIApplication sharedApplication]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(applicationWillResignActive:) 
                                                 name:UIApplicationWillResignActiveNotification 
                                               object:app]; 
    [super viewDidLoad]; 

 
 
/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */ 
 
- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 
     
    // Release any cached data, images, etc that aren't in use. 

 
- (void)viewDidUnload { 
    self.field1 = nil; 
    self.field2 = nil; 
    self.field3 = nil; 
    self.field4 = nil; 
    [super viewDidUnload]; 

 
 
- (void)dealloc { 
    [field1 release]; 
    [field2 release]; 
    [field3 release]; 
    [field4 release]; 
    [super dealloc]; 

 
@end 

4、Core Data

復制代碼 代碼如下:

// 
//  PersistenceViewController.h 
//  Persistence4 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import <UIKit/UIKit.h> 
 
 
@interface PersistenceViewController : UIViewController { 
    UITextField *filed1; 
    UITextField *field2; 
    UITextField *field3; 
    UITextField *field4; 

@property (nonatomic, retain) IBOutlet UITextField *field1; 
@property (nonatomic, retain) IBOutlet UITextField *field2; 
@property (nonatomic, retain) IBOutlet UITextField *field3; 
@property (nonatomic, retain) IBOutlet UITextField *field4; 
 
@end 

復制代碼 代碼如下:

// 
//  PersistenceViewController.m 
//  Persistence4 
// 
//  Created by liu lavy on 11-10-3. 
//  Copyright 2011 __MyCompanyName__. All rights reserved. 
// 
 
#import "PersistenceViewController.h" 
#import "Persistence4AppDelegate.h" 
 
@implementation PersistenceViewController 
@synthesize field1; 
@synthesize field2; 
@synthesize field3; 
@synthesize field4; 
 
 
-(void) applicationWillResignActive:(NSNotification *)notification { 
    Persistence4AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; 
    NSManagedObjectContext *context = [appDelegate managedObjectContext]; 
    NSError *error; 
    for(int i = 1; i <= 4; i++) { 
        NSString *fieldName = [NSString stringWithFormat:@"field%d", i]; 
        UITextField *theField = [self valueForKey:fieldName]; 
         
        //創建提取請求 
        NSFetchRequest *request = [[NSFetchRequest alloc] init]; 
        //創建實體描述并關聯到請求 
        NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Line" 
                                                             inManagedObjectContext:context]; 
        [request setEntity:entityDescription]; 
         
        //設置檢索數據的條件 
        NSPredicate *pred = [NSPredicate predicateWithFormat:@"(lineNum = %d)", i]; 
        [request setPredicate:pred]; 
         
        NSManagedObject *theLine = nil; 
        ////檢查是否返回了標準匹配的對象,如果有則加載它,如果沒有則創建一個新的托管對象來保存此字段的文本 
        NSArray *objects = [context executeFetchRequest:request error:&error]; 
        if(!objects) { 
            NSLog(@"There was an error"); 
        } 
        //if(objects.count > 0) { 
        //  theLine = [objects objectAtIndex:0]; 
        //} else { 
            //創建一個新的托管對象來保存此字段的文本 
            theLine = [NSEntityDescription insertNewObjectForEntityForName:@"Line" 
                                                    inManagedObjectContext:context]; 
            [theLine setValue:[NSNumber numberWithInt:i] forKey:@"lineNum"]; 
            [theLine setValue:theField.text forKey:@"lineText"]; 
        //} 
        [request release]; 
    } 
    //通知上下文保存更改 
    [context save:&error]; 
     

 
// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. 
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/ 
 
 
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad { 
    Persistence4AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; 
     
    NSManagedObjectContext *context = [appDelegate managedObjectContext]; 
    //創建一個實體描述 
    NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Line" inManagedObjectContext:context]; 
    //創建一個請求,用于提取對象 
    NSFetchRequest *request = [[NSFetchRequest alloc] init]; 
    [request setEntity:entityDescription]; 
     
    //檢索對象 
    NSError *error; 
    NSArray *objects = [context executeFetchRequest:request error:&error]; 
    if(!objects) { 
        NSLog(@"There was an error!"); 
    } 
    for(NSManagedObject *obj in objects) { 
        NSNumber *lineNum = [obj valueForKey:@"lineNum"]; 
        NSString *lineText = [obj valueForKey:@"lineText"]; 
        NSString *fieldName = [NSString stringWithFormat:@"field%d", [lineNum integerValue]]; 
        UITextField *textField = [self valueForKey:fieldName]; 
        textField.text = lineText; 
    } 
    [request release]; 
     
    UIApplication *app = [UIApplication sharedApplication]; 
    [[NSNotificationCenter defaultCenter] addObserver:self  
                                             selector:@selector(applicationWillResignActive:)  
                                                 name:UIApplicationWillResignActiveNotification 
                                               object:app]; 
    [super viewDidLoad]; 

 
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/ 
 
- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 
     
    // Release any cached data, images, etc. that aren't in use. 

 
- (void)viewDidUnload { 
    self.field1 = nil; 
    self.field2 = nil; 
    self.field3 = nil; 
    self.field4 = nil; 
    [super viewDidUnload]; 

 
 
- (void)dealloc { 
    [field1 release]; 
    [field2 release]; 
    [field3 release]; 
    [field4 release]; 
    [super dealloc]; 

 
 
 
@end 

5、AppSettings
復制代碼 代碼如下:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 

6、普通文件存儲

這種方式即自己將數據通過IO保存到文件,或從文件讀取。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
久久久免费高清电视剧观看| 国产精品一区久久| 日韩电影免费观看在线观看| 久久视频在线观看免费| 丝袜美腿精品国产二区| 91在线免费视频| 国产精品96久久久久久| 黑丝美女久久久| 久久视频在线免费观看| 在线播放日韩精品| 亚洲精品一区二三区不卡| 国产精品亚洲欧美导航| 欧美性高潮床叫视频| 国产亚洲成精品久久| 色偷偷88888欧美精品久久久| 欧美有码在线观看视频| 波霸ol色综合久久| 日韩精品免费在线| 国产精品成人国产乱一区| 欧美精品手机在线| 69视频在线免费观看| 亚洲欧美日韩一区在线| 欧美日韩在线第一页| 亚洲自拍偷拍区| 国产精品一区专区欧美日韩| 成人妇女免费播放久久久| 日本老师69xxx| 久久中文字幕在线| 亚洲男人的天堂在线播放| 久久精品久久精品亚洲人| 久久久久久久久网站| 亚洲网站在线播放| 亚洲男人天堂网站| 亚洲视频在线视频| 欧美理论电影在线观看| 欧美中文字幕第一页| 91九色蝌蚪国产| 亚洲另类xxxx| 日韩激情在线视频| 97视频在线免费观看| 欧美午夜精品久久久久久浪潮| 中文欧美日本在线资源| 欧美日韩国产在线播放| 日韩成人av一区| 精品人伦一区二区三区蜜桃网站| 日韩在线国产精品| 亚洲福利视频二区| 久久亚洲精品一区二区| 亚洲第一二三四五区| 精品调教chinesegay| 成人网在线免费看| 精品久久久久久久久久久久| 欧美日韩国内自拍| 欧美日韩亚洲视频| 这里只有精品视频| 日韩成人激情影院| 欧美激情欧美激情在线五月| 国产啪精品视频| 国产91精品最新在线播放| 91在线视频成人| 久久夜精品va视频免费观看| 亚洲国产另类久久精品| 欧美在线观看视频| 欧美中文在线免费| 国产精品99久久久久久www| 国产精品永久免费| 7777免费精品视频| 亚洲白虎美女被爆操| 92版电视剧仙鹤神针在线观看| 久久久精品国产一区二区| 久久国产天堂福利天堂| 久久久91精品国产| 国产精品精品视频| 国产精品1234| www.久久草.com| 日韩中文字幕欧美| 日韩小视频在线| 久久久久久久999精品视频| 91av在线精品| 欧美午夜精品伦理| 国产午夜精品视频| 97视频免费在线看| 91在线国产电影| 国产精品自产拍高潮在线观看| 在线精品国产成人综合| 日韩av大片免费看| 日韩禁在线播放| 欧美电影免费观看高清| 成人有码视频在线播放| 色www亚洲国产张柏芝| 国产精品久久久久久久久久久久久久| 国产精品永久免费| 午夜精品在线观看| 欧美极品xxxx| 日韩av电影中文字幕| 精品亚洲永久免费精品| 国内精品中文字幕| 欧美成人在线网站| www.日本久久久久com.| 久久久噜噜噜久久| 欧美黄网免费在线观看| 91九色精品视频| 日韩女在线观看| 欧美夫妻性视频| 欧美日韩国产在线看| 精品国产一区二区在线| 成人激情免费在线| 亚洲国产精彩中文乱码av| 97国产精品视频人人做人人爱| 久久6精品影院| 中日韩午夜理伦电影免费| 日韩精品免费一线在线观看| 日韩av在线播放资源| 欧美大片大片在线播放| 97久久精品人人澡人人爽缅北| 国产午夜精品久久久| 欧美性感美女h网站在线观看免费| 日韩精品欧美激情| 亚洲人午夜精品免费| 欧美日韩国产一区在线| 午夜精品久久久久久久99热| 国产欧美韩国高清| 久久久久久久久爱| 国产欧美一区二区三区久久人妖| 91精品国产色综合久久不卡98口| 欧美日韩国产激情| 国产一级揄自揄精品视频| 国产日本欧美一区二区三区| 中文字幕在线观看亚洲| 日韩中文在线中文网在线观看| 中文字幕九色91在线| 亚洲va国产va天堂va久久| 亚洲精品国产美女| 国产精品入口尤物| 日韩av成人在线| 欧美性猛交xxxx偷拍洗澡| 日韩中文字幕在线免费观看| 欧美日韩精品在线播放| 麻豆一区二区在线观看| 在线成人一区二区| 久久久国产在线视频| 亚洲成人久久久久| 青青精品视频播放| 国产精彩精品视频| 国产精品久久久久久久7电影| 精品精品国产国产自在线| 欧美视频中文在线看| 91成品人片a无限观看| 日韩在线视频中文字幕| 亚洲免费中文字幕| 成人av电影天堂| 欧美天堂在线观看| 成人自拍性视频| 亚洲精品97久久| 欧美激情国产日韩精品一区18| 精品日韩视频在线观看| 亚洲精品v欧美精品v日韩精品| 久久精品国产久精国产一老狼| 插插插亚洲综合网| 日韩在线一区二区三区免费视频| 亚洲色图第一页| 日韩中文字幕久久| 亚洲美女视频网站| 九九久久综合网站|