6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Objective-CでJavaの拡張for文っぽく書きたい

Posted at

方法としてはObjective-Cの高速列挙と呼ばれる機能を使用する。
Javaの拡張for文に近くて書きやすい。
名前の通り普通にfor回すよりだいぶ処理速度が速いようなので、使わない理由は無い。

Demo.m
NSMutableArray *animeList = [NSMutableArray new];
for (NSDictionary *anime in jsonArray) {
    Anime *tmpAnime = [[Anime alloc] initWithJSONObject:anime];
    [animeList addObject:tmpAnime];
}
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?