Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
iOS app Development - Block
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
高見龍
April 15, 2014
Programming
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
iOS app Development - Block
高見龍
April 15, 2014
More Decks by 高見龍
See All by 高見龍
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
660
自己的售票系統自己做!
eddie
0
670
AI Agent 時代的開發者生存指南
eddie
4
2.8k
print("Hello, World")
eddie
2
680
為你自己學 Python - 冷知識篇
eddie
1
500
為你自己學 Python
eddie
0
810
Generative AI 年會小聚 - AI 教我寫程式
eddie
0
260
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
800
AI 時代的程式語言學習法
eddie
0
310
Other Decks in Programming
See All in Programming
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
180
Agents on Rails - Rails at Scale 2026
irinanazarova
0
120
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
290
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
500
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
250
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
180
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
250
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
230
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
350
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
130
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
510
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
300
Featured
See All Featured
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
510
Why Our Code Smells
bkeepers
PRO
340
58k
Claude Code のすすめ
schroneko
67
230k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
500
We Have a Design System, Now What?
morganepeng
55
8.3k
So, you think you're a good person
axbom
PRO
2
2.2k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
Faster Mobile Websites
deanohume
310
32k
Transcript
iOS App Development Lesson 15 - Block Eddie Kao
define a block int (^myAdd)(int, int); myAdd = ^(int a1,
int a2) { return a1 + a2; };
define a block int (^myAdd)(int, int) = ^(int a1, int
a2) { return a1 + a2; };
call a block myAdd(2, 3);
no return type and params void (^myBlock)(void) = ^(void) {
NSLog(@"Hello, Block"); }; myBlock();
no return type and params (cont.) void (^myBlock)() = ^{
NSLog(@"Hello, Block"); }; myBlock();
get variable out of the block int mutiplier = 10;
int (^myAdd)(int, int) = ^(int a1, int a2) { return (a1 + a2) * mutiplier; };
define type for block typedef int (^MyBlockType) (int, int); MyBlockType
myAddType = ^(int a1, int a2) { return a1 + a2; };
return value to block typedef void (^CompleteBlock) (NSString* title, NSString*
author); typedef void (^FailBlock) (NSError* error); @interface DemoClass : NSObject - (void) fetchBookWithID:(NSInteger) bookID complete:(CompleteBlock) complete fail:(FailBlock) fail; @end @implementation DemoClass - (void) fetchBookWithID:(NSInteger)bookID complete:(CompleteBlock)complete fail:(FailBlock)fail { if (/.. something error.. /) { fail(error); } else { complete(@"This is a book", @"eddie kao"); } } @end
return value to block (cont.) DemoClass* demo = [[DemoClass alloc]
init]; [demo fetchBookWithID:10 complete:^(NSString *title, NSString *author) { NSLog(@"book title = %@, and author = %@", title, author); } fail:^(NSError *error) { NSLog(@"error = %@", error); }];
for-in v.s block enumeration NSArray* array = @[@1, @2, @3,
@4, @5]; for (id obj in array) { NSLog(@"%@", obj); } [array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSLog(@"%@", obj); }];
replace delegation with block
UIAnimation, the old way - (void)viewDidLoad { [super viewDidLoad]; UIView*
myView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; myView.backgroundColor = [UIColor redColor]; [self.view addSubview:myView]; [UIView beginAnimations:@"Demo" context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(endAnimationHandler)]; [UIView setAnimationDuration:3]; myView.alpha = 0; [UIView commitAnimations]; } - (void) endAnimationHandler { NSLog(@"animation end!"); }
UIAnimation, the block way - (void)viewDidLoad { [super viewDidLoad]; UIView*
myView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; myView.backgroundColor = [UIColor redColor]; [self.view addSubview:myView]; [UIView animateWithDuration:3 animations:^{ myView.alpha = 0; } completion:^(BOOL finished) { NSLog(@“animation end!”); }]; }
So, Why not use Block?
and Why use Block?
Keeps code together
and Apple says so!