Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-11-2009, 12:30 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: Bhubaneswar(INDIA)
Posts: 39
ajitbiswal is on a distinguished road
Default NSString

can anyone explain me the function below.specifically for void(^) and the block..what does the block mean here..


- (void)enumerateLinesUsingBlockvoid (^)(NSString *line, BOOL *stop))block
Parameters
block
The block executed for the enumeration.
The block takes two arguments:
line
The to enumerate containing just the contents of the line, without the line terminators.
stop
A reference to a Boolean value that the block can use to stop the enumeration by setting
*stop = YES; it should not touch *stop otherwise.
ajitbiswal is offline   Reply With Quote
Old 09-11-2009, 12:56 AM   #2 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Quote:
Originally Posted by ajitbiswal View Post
can anyone explain me the function below.specifically for void(^) and the block..what does the block mean here..
The void (^) is a new kind of pointer that can be used to point to "blocks", also called anonymous functions or closures. It's a way to have pointers to functions and call those functions later. It's a new feature, so you won't find it in many books. More info here:

mikeash.com: Friday Q&A 2008-12-26

Found some example code here, but nothing with NSString: Programming with C Blocks on Apple Devices

Note that enumerateLinesUsingBlock doesn't exist on the iPhone; it's Mac OS 10.6 only.
__________________

Free Games!

Last edited by smasher; 09-11-2009 at 11:40 AM.
smasher is offline   Reply With Quote
Old 09-11-2009, 02:25 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: Bhubaneswar(INDIA)
Posts: 39
ajitbiswal is on a distinguished road
Default

Quote:
Originally Posted by smasher View Post
The void (^) is a new kind of pointer that can be used to point to "blocks", also called anonymous functions or closures. It's a way to have pointers to functions, can call those functions later. It's a new features, so you won't find it in many books. More info here:

mikeash.com: Friday Q&A 2008-12-26

Found some example code here, but nothing with NSString: Programming with C Blocks on Apple Devices

Note that enumerateLinesUsingBlock doesn't exist on the iPhone; it's Mac OS 10.6 only.
i got it...thanks a lot...
ajitbiswal is offline   Reply With Quote
Old 09-11-2009, 03:16 PM   #4 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

After my curiosity was piqued, I found a clearer explanation from apple:
ADC—Introducing Blocks and Grand Central Dispatch
__________________

Free Games!
smasher is offline   Reply With Quote
Old 09-15-2009, 04:18 AM   #5 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: Bhubaneswar(INDIA)
Posts: 39
ajitbiswal is on a distinguished road
Default

Quote:
Originally Posted by smasher View Post
After my curiosity was piqued, I found a clearer explanation from apple:
ADC—Introducing Blocks and Grand Central Dispatch
I already read the book objective c 2.0 from apple but as a beginner it is very difficult for me to catch up all the details. From various resources I come to know that Programming in Objective-C 2.0 By Stephen G. Kochan is one of the best book for iphone development but neither I am able to download it nor able to read it online freely. Could you help me .It is a very much need for me.
ajitbiswal is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 457
13 members and 444 guests
Domele, Duncan C, Feldspar, MacBook MH, Objective Zero, patapple, peterwilli, pipposanta, PixelInteractive, Punkjumper, SLIC, taylor202, Today's Posts
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,694
Threads: 94,137
Posts: 402,950
Top Poster: BrianSlick (7,990)
Welcome to our newest member, peterwilli
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:03 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0