Introduction In the first article of this series, we learned about the Core Data stack, the heart of a Core Data application. We explored the managed object context, the persistent store coordinator, and the managed object model. This article focuses on the data model of a Core Data application. We zoom in on Xcode's data model editor and we take a look at entities, attributes, and relationships.
NSPredicateで使用できる全構文の解説です。 確認に使用したサンプルコードはこちらです。 NSPredicate Programming Guide - Predicate Format String Syntaxに記載しているのは全て取り上げていますが、SUBQUERYがNSExpressionに書いてあったりしたからまだ他にもあるのかもしれません。 あと@を指定して使用する関数のドキュメントが見つからなかった・・・ドキュメントが乱雑し整理されていない感じがしました。 関連キーワード: BNF, NSExpression 注意: SQLと同じ用語には注意が必要です。例えばANYはSQLのANYとは異なります。 リテラル %@ 文字列として扱われる(ダブルクォーテーションで囲われる) NSString *attributeValue = @"Anne"; NSPredicate *
NTYPopulatorというiOS/OS X用のライブラリを書いた。これはCore Data向けに初期データを用意する。 インストールCocoaPodsに公開したので、pod "NTYPopulator"からインストールできる。 使い方最も簡単な使い方はAppDelegate.mに一行追加するだけで良い。 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[NTYPopulator new] run]; return YES; } この一行はリソースバンドル内にあるseeds/*.csvを探し出し、ファイル名と同名のEntityに初期データを追加する。例えば、seeds/user.csvというファ
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[NTYPopulator new] run]; return YES; } リソースバンドル内にあるseeds/*.csvを探しだして、ファイル名と同名のEntityにデータを追加する。例えば、seeds/user.csvのデータはUserというEntityに追加される。 デフォルトではモデルファイルとしてModel.momdが参照され、SQLiteファイルとして$(CFBundleName).sqliteが参照される。これを変更することも可能。 - (BOOL)application:(UIApplication *)application didFinishLau
前から疑問だったのですが、Core Data Programming Guideにやり方が書いてありました。ていうか先月の3月10日に追記されたっぽいです。 Core Data Programming Guide: Non-Standard Persistent Attributes Scalar Valuesっていうところに書いてあります。 追記 コメントで @ishkawa@github さんに教えてもらいましたが、enumの場合はもっと簡単というか普通に実装する方法があるみたいでした。Core Data Programming Guideに書いてあるのは、doubleやCGRectを入れる場合の方法みたいですね。ishkawaさんありがとうございました! 何がしたいのか たとえばこういう列挙型を定義したとして…。 typedef NS_ENUM(NSUInteger, kServic
It's actually quite easy to replace your Core Data backing store even while your application is in use. For example, you may want to replace all the data on the device when a user restores from a backup. In this scenario you could perform the import operation using a separate store, quickly replacing the current store when the data has been restored. So let's say we've finished building our new st
Below you will find a collection of resources for making Core Data fast. Learn how to analyze, debug, and squeeze every last bit of performance out of Core Data. The standard Core Data implementation is very powerful and flexible but lacks performance. This advanced talk covers various performance analysis tools, data model optimization, and various high performance concurrency models. This is an
UPDATED on Oct 2015: With the new awesome Swift, do check out the new NSFetchedResultsController guide. This is an adaptation of a cheat sheet on iosdevblog.com. The original post provides the code to implement NSFetchedResultsController, but without MagicalRecord. This post will provide the code with MagicalRecord. Declare a NSFetchedResultsController and delegate @interface PoosViewController :
Update: This tutorial has been updated for iOS 8 and Swift here. This Objective-C version is no longer supported but is here for reference. For many years, Core Data has been an integral part of many OS X and iOS apps, supporting the persistence and querying of user data. Apple constantly tinkers with Core Data API, in an effort to make it easier for developers to use and integrate into apps. That
NSManagedObjectのプロパティをstubしようと思ってめっちゃはまった. こんな風に普通にstubしようとしてもstubできない. // こんなNSManagedObjectのサブクラスがあるとする // @interface Event : NSManagedObject // @property (nonatomic, retain) NSDate * timeStamp; // @property (nonatomic, retain) NSString * title; // @end id mock = [OCMockObject mockForClass:Event.class]; [[[mock stub] andReturn:@"test"] title]; XCTAssertTrue([[mock title] isEqualToString:@"test"]
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く