Tag: sqlite

使用照片构buildSQLite数据库

我打算在UICollectionView控制器中显示用户从DetailViewController收集的图像。 我想使用一个SQLite数据库,但我不确定如何启动它,看到我已经有大部分的应用程序build立和build立。 下面看到我的DetailViewController(图像收集和显示),ImageStore.swift(图像当前正在存储)和UICollectionView控制器。 ImageStore.swift: class ImageStore: NSObject { let cache = NSCache() func setImage(image: UIImage, forKey key: String) { cache.setObject(image, forKey: key) let imageURL = imageURLForKey(key) if let data = UIImageJPEGRepresentation(image, 0.5) { data.writeToURL(imageURL, atomically: true) } } func imageForKey(key: String) -> UIImage? { if let existingImage = cache.objectForKey(key) as? UIImage { return existingImage } […]

在Swift中NSlogging / println SQLite数据库文件的位置

所以我想弄清楚我的swift IOS应用程序在哪里存储它的SQLite数据库文件。 我知道applicationsDocumentsDirectory存储目录。 我需要find一种方法来打印它在控制台或NSLog它。 我是新来的迅速和IOS的发展,所以我在这里遇到麻烦。 我试着只是在另一个类中调用variables,也只是在clojure中没有成功的NSLogging。 有任何想法吗? 这是variables。 lazy var applicationDocumentsDirectory: NSURL = { // The directory the application uses to store the Core Data store file. This code uses a directory named "arux-software.onsite_childcare" in the application's documents Application Support directory. let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) return urls[urls.count-1] as NSURL }()

修复崩溃:严重失败:LastResort字体不可用

我正在使用本教程使用sqlite插入10000条目 在我的viewcontroller.m使用这个代码 – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. [self AddTHousandsOfEntry]; } -(void)AddTHousandsOfEntry { for (int i=0; i<100500; i++) { NSString *regNo=[NSString stringWithFormat:@"%d",i]; NSString *name=[NSString stringWithFormat:@"name%d",i]; NSString *department=[NSString stringWithFormat:@"department%d",i]; NSString *year=[NSString stringWithFormat:@"year%d",i]; if (regNo.length>0 &&name.length>0 && department.length>0 &&year.length>0 ) { [[DBManager getSharedInstance]saveData:regNo name:name department: department […]

在ios应用程序中保存和查看图像

我刚开始开发一个像联系人一样的iOS应用程序。 包括姓名,生日,群组(学校,工作),血型,图片等。 在那里,其他数据可以通过键入来插入。 但是,图像可以来自拍照,从Facebook下载..等。 input图像到xcode是不可能的。 Bcoz,另一个图像可以一次又一次地来。 我应该怎么做? 请,请教我。

iOS Sqlite3 SQLITE_ERROR

我有一个iOS应用程序的function,从数据库中读取一些数据。 该function非常简单: -(void) readCategories { sqlite3 *database; if([[NSFileManager defaultManager] fileExistsAtPath:databasePath]){ if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { const char *sqlStatement = "SELECT * FROM Categories ORDER BY name COLLATE NOCASE ASC"; sqlite3_stmt *compiledStatement; int errorCode = sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL); if(errorCode == SQLITE_OK) { while(sqlite3_step(compiledStatement) == SQLITE_ROW) { [categories addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)]]; } } […]

ios – sqlite准备语句

我想从一个iOS应用程序中的数据库中读取数据。 当我运行应用程序,它能够打开数据库,但在日志文件中显示消息 – “与准备声明的问题”。 我不知道我的准备声明有什么问题这是我的代码 – -(NSString *)dataFilePath{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:kFilename]; } 在viewDidLoad中我有 – – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. myarray = [[NSMutableArray alloc]init]; sqlite3 *database; if(sqlite3_open([[self dataFilePath]UTF8String], &database)!=SQLITE_OK){ sqlite3_close(database); NSAssert(0, @"Failed […]

在上下文崩溃的情况下保存核心数据

我有一个方法创build一个单独的线程: // Create thread dispatch_queue_t uniqueQueue = dispatch_queue_create("Unique Email Queue", NULL); // Run block on another thread called downloadQueue dispatch_async(uniqueQueue, ^{ // Get the persistance store coordinator AppDelegate* appDelegate = [UIApplication sharedApplication].delegate; self.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator; // Setup the managed object context NSManagedObjectContext *managedObjectContext = [[NSManagedObjectContext alloc] init]; [managedObjectContext setPersistentStoreCoordinator:self.persistentStoreCoordinator]; // Save to core data for […]

sqlite查询来查找给定date的一年的总和

我写了一个查询: SELECT YEAR(Date),SUM(replace(price, ',', '')) FROM example GROUP BY year(date); 。我试图得到那一年的所有价格的总和,但我得到一个错误 – 没有这样的function:一年。 请指导我,我是db的noob。再次感谢。 12/10/11 377,245.67 12/19/11 5,104,245.00 12/28/11 23,332.98 12/24/10 126,875.21 12/24/10 5,112,225.14 12/23/10 4,552.54 11/24/10 402.82 10/15/09 132,875.32 9/19/09 126,334,123.32 9/23/09 345,887.21 9/29/09 16,520.11 9/28/09 388,902.02 11/12/08 24,622.43 10/25/08 278,916.52 10/12/08 42.22 9/22/08 17,234.01 9/16/08 377,245.67 12/15/07 5,104,245.00 12/18/07 23,332.98 12/19/07 126,875.21 12/22/07 […]

在sqlite中更改date格式

更改date格式这是在sqlite数据库12/10/11 to 12-10-11 (mm-dd-yy)我无法这样做。我是一个noob在sqlite中,必须parsing此值SELECT strftime('%d-%m-%Y',Date) from report但我越来越null作为sqlite数据库除了价值在mm-dd-yy所以如何转换格式12/10/11 to 12-10-11 (mm-dd-yy) 。预先感谢。真的很感谢帮助。

更新应用程序以使用先前双SQLite持久性存储的Core Data

我目前正在升级使用两个SQLite dbs的旧版iPhone闪存卡应用程序(其中一个只能通过应用程序更新,删除卡,添加卡,卡更新以及另一个用户添加它们的只读问题自己的自定义卡),而不是使用核心数据。 用于区分只读卡和用户添加卡的“Flashcard”对象的唯一属性是“isCustom”属性。 以下是我认为有必要这样做的步骤: (首先从2个SQLite数据库更新到CoreData) 从用户自定义卡数据库获取所有自定义卡条目。 使用只读卡添加新的Core Data对象模型,然后将用户添加的自定义卡加载到此模型中。 删除旧的SQLite数据库(自定义卡数据库和只读卡数据库)。 (将来会有一个核心数据模型的更新) 从当前核心数据持久性存储中获取所有定制卡片。 将所有自定义卡迁移到新的Core Data持久性存储。 我只想确定在开始从头开始devise这个系统之前,这是否是一条路。 任何提示将不胜感激。