Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?

これは、Core Dataで管理するデータをJSONで返すHTTPサーバーをiOSアプリケーション内に起動し、スキーマに基づいたRESTfulなAPIを提供する。平たく言えば、iOSアプリケーション内にWebアプリケーションを作っている。 サーバーを起動するコードを数行書くと、アプリ内でHTTPサーバーが起動しスクリーンショットにあるようにリクエストに対してJSONを返すようになる。Userというエンティティをサーバーで返すように設定すると、/users.jsonや/users/Alice.jsonのようなAPIが自動的に提供される。Core Dataは通常のORMとは異なりidが自動的に用意されるわけではなく自分でそのようなユニークなカラムを定義する必要があるため、単一のリソースを取得する場合はキーとなるカラムを起動時に明示する必要がある。
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"]
CoreDataを使う場合、Model(テーブル定義みたいなもの)を変更すると、 マイグレーションが走る。 例えば新しく追加されたカラムについてデフォルト値をどうするかなど。 それをGUIで設定できる反面、各モデルバージョンからのマージ内容を毎回作成しないといけないので、 必ず設定し忘れがある。 マージポリシーなど個別に実装すればよいのだが、ひとまずテストを書いて、 設定漏れがないようにする。 sqlitenの作成 dataに各モデルバージョンのsqliteを置いておく Data1.sqlite (Version1) Data2.sqlite (Version2) CoreDataManager CoreDataを扱うクラス @interface CoreDataManager : NSObject { NSManagedObjectModel *managedObjectModel; N
Swift is the best programming language you should learn and make your dream app easily. Swift programming is a powerful yet easy-to-learn coding language created by Apple. It's frequently used for developing iOS and macOS applications, as well as tvOS and watchOS apps. While you can use other languages to create Apple apps, Swift is the preferred language, and it's recommended because its code is
Whether you subscribe to Test Driven Development (TDD) or another testing practice, when it comes automated unit testing with Core Data, things can be a little tricky. But if you keep it simple, and take things step by step, you can get up and running with unit testing using Core Data fairly quickly. We’ll explore the what, how and why of unit testing with Core Data. We’ll also be using the helper
Objective-CCoreData使った処理とかのテストを書きたい訳です。ある程度CoreData使ってなんとなく雰囲気理解できてる人向けに書いてます。下準備アプリに使われてるdbそのまま使うみたいな方法もあるけど、tearDownで掃除するとか面倒くさいし、モックみたいなの作れればいいんだけどなー的な。方法としてはアプリに使うデータモデルだけ引き抜いてきてメモリにManagedObjectContextを作ってみた。何回も同じの書くのはめんどくさいので、ベースにするクラス作っておけばいいと思う。 #import @interface CoreDataBaseTest : SenTestCase { NSManagedObjectContext *_managedObjectContext; NSManagedObjectModel *_managedObjectModel; NSP
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く