Please note: this article is part of the older "Objective-C era" on Cocoa with Love. I don't keep these articles up-to-date; please be wary of broken code or potentially out-of-date information. Read "A new era for Cocoa with Love" for more. If you need to store a reference to an NSManagedObject outside of an NSManagedObjectContext, then you'll need to convert NSManagedObjects to URIs and back aga
ARC (Automatic Reference Counting) を有効にすると、従来のソースコードを大幅に修正する必要がでてくるため、それまでに作成していたプログラムをまるごと ARC に移行するのは、なかなか困難な場合もあると思います。 この ARC を使うかどうかの設定ですが、ARC を有効にする で記したプロジェクト単位での設定の他にも、ファイル単位でも設定できるようになっていました。 ファイル単位で ARC の有効化または無効化は、プロジェクトの "TARGET" の設定で行います。 プロジェクトの "TARGET" を選択したら、そこの "Build Phases" から "Compile Sources" を選択します。 ここで、ARC の有効化や無効化を個別に設定したいソースファイルをダブルクリックして、コンパイラーオプションとして、次の値を設定します。
Objective-C と Swift とでは、それぞれで定義したクラスを簡単に相互利用できるようになっています。 ここでは Objective-C で定義したクラスを Swift で利用する方法を紹介します。Swift で定義したクラスを Objective-C で利用する方法については Swift で定義したクラスを Objective-C で利用する で紹介します。 Objective-C のクラスを Swift で利用できるようにするための準備 ブリッジヘッダーファイルを用意する Objective-C のクラスを Swift から利用できるようにするためには、どの Objective-C クラスを Swift で利用するかを記載したブリッジヘッダーファイルをプロジェクト内に用意する必要があります。 このブリッジヘッダーファイルは一般的に "$(TARGET_NAME)-Bridg
kishikawakatsumi/JavaScriptBridge · GitHub 前にiOS 7から導入されたJavaScriptCore.frameworkを使ってUIKit標準のクラスを操作する話を書きました。 JavaScriptだけでiOSのUIを書いてみる - 24/7 twenty-four seven JavaScriptCoreを使ってJavaScriptからObjective-Cのオブジェクトを操作するのは、あらかじめJSExportプロトコルで公開しておく必要があるなど、あまり実用的ではありませんでしたが、このライブラリを導入すうることで、そういった事前準備がすでに済んでいる状態で使いはじめることができます。 また、JavaScriptからObjective-Cのクラスを定義できるなどいくつかの拡張を加えてあり、UIViewControllerのサブクラスで画面を定
I have two entities, each displaying on its own UITableView section. I've enabled editing to allow the user to delete rows by swiping to the right. This works fine for the first entity, but when I try to delete an object in the second entity, I get this error: An NSManagedObjectContext cannot delete objects in other contexts I get what the error says, but I can't see how it applies here. I use a r
Two weeks ago I wrote about the huge performance differences between various concurrent core data stack setups when importing data. The old-school setup with two independent contexts using the same persistent store coordinator turned out to have a much smaller performance impact on the main thread compared to an alternative parent/child setup. In this article I will take a look behind the scenes o
A few weeks ago I wrote about a concurrent core data stack setup which uses the nested context feature introduced with iOS 5. This setup was recommended amongst others by Marcus Zarra. It seemed elegant and straightforward, while putting the majority of the heavy lifting on a background thread. I was wondering though how much the main thread will be affected in this setup by extensive work done in
NSPredicate の話を求めて、このブログへ訪れる方が多いようなので、NSPredicate の使い方を紹介しようと思います。 NSPredicate は、NSArray で要素をフィルターするための条件を表したり、Core Data で取ってくるデータの条件を表すためのクラスです。 NSPredicate を作成する方法として最も簡単なものが、predicateWithFormat です。これを用いると、NSPredicate 独自の記法ではありますが、自然な記述で条件を書くことができます。 Predicate の条件式の基本形は、”keyPath operator literal” です。それぞれには、次のようなものが入ります。 keyPath キー値コーディングのキーパス。この値が条件の判定に利用されます。self 指定すると、そのオブジェクト自体の値が利用されます。(self
I'm having some trouble using NSPredicate predicateWithFormat:argumentArray:. In this example, serverIDList is array of strings. Results is an array of NSManagedObjects with an attribute named "flid" which is a string. NSMutableString *predicateString = [[NSMutableString alloc] init]; [predicateString appendString:@"(flid IN %@)"]; [results filterUsingPredicate:[NSPredicate predicateWithFormat:pre
Can’t get enough info about iOS 8? Join us for our one-day iOS 8 bootcamps in cities across the U.S. Core Data has had a polarizing effect within the development community. You’d be hard pressed to meet a Cocoa developer who is completely ambivalent to the topic. I won’t mask my opinion: I am a true fan. I believe that Apple has made significant improvements to the framework each year. This year w
たとえば下記のように、delegate プロトコルと、それをプロパティに持つクラスを定義し、 @protocol HogeManagerDelegate <NSObject> @end @interface HogeManager : NSObject @property (nonatomic, weak) id<HogeManagerDelegate> delegate; @end HogeViewController で下記のように `setDelegate:` するとします。 [[HogeManager sharedManager] setDelegate:self]; で、これを Xcode 6 でビルドすると、 warning: sending 'HogeViewController *const __strong' to parameter of incompatible ty
データ件数は、Customerが 500件、Karteが6,000件(Customer1件につきKarte 12件)となっていて、それぞれを1つの CSVファイルへ書き出す。 処理は次のような感じになる。 NSMangedObjectContext* moc = [取得]; NSArray* customers = [moc Customer全件取得]; for (NSManagedObject* customer in customers) { NSArray* kartes = [moc Karte取得・条件:customer]; for (NSManagedObject* karte in kartes) { [CSV1行書き出し]; } }メモリのフットプリント(利用状況)はこんな感じ。 Customer, Karte を1件づつ読み込む度にメモリが消費され、フットプリントが増大し
MKiCloudSync を使用すると、たった1行コードを追加しておくだけで、あとは自動的に NSUserDefaults の内容を iCloud に同期してくれます。 もともとシンプルな iCloud 同期ですが、もっとシンプルになるのでとりあえず iCloud 対応したい、ちょっと試してみたい、等の場合にオススメです。 使い方 1. ソースをダウンロード https://github.com/MugunthKumar/MKiCloudSync 2. ヘッダをインポート #import "MKiCloudSync.h" 3. start メソッドをコール AppDelegate の application:didFinishLaunchingWithOptions: 内で、以下のように start メソッドをコール [MKiCloudSync start]; たったこれだけ。 「おいおい
Written by Mattt August 15th, 2018 (revised) This article has been translated into: 中文 The concept of equality is a central topic in philosophy and mathematics, with far-reaching implications for matters of ethics, justice, and public policy. From an empiricist perspective of the universe, two objects are equal if they’re indistinguishable by measurable observation. On a human scale, egalitarians
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く