How To Use Blocks in iOS 5 Tutorial - Part 2
27 posts
• Page 1 of 3 • 1, 2, 3
How To Use Blocks in iOS 5 Tutorial - Part 2
This is the official thread to discuss the following blog post: How To Use Blocks in iOS 5 Tutorial - Part 2
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

rwenderlich - Site Admin
- Posts: 1776
- Joined: Thu Dec 23, 2010 4:14 pm
- Has thanked: 26 times
- Been thanked: 187 times
Re: How To Use Blocks in iOS 5 Tutorial Part 2
Hey Adam,
Here is my question I mentioned on twitter.
If the parent view is a viewcontroller that has a child of uitableview and uitableviewcell. we'll call the first uitableviewcell the 1st cell. In 1st cell i have a uitableview and 1st cell also has a child of a uitableview delegate/data source with a 2nd cell. Right not I implement a delegate on 1st cell and when the method -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath gets called i pass which cell was selected through the 1st cell delegate method to the view controller to handle any UI changes. Anyway to handle this behavior with blocks? I've been trying to figure that out and implement more blocks through my app and these tutorials have been a huge help!
Kyle
Here is my question I mentioned on twitter.
If the parent view is a viewcontroller that has a child of uitableview and uitableviewcell. we'll call the first uitableviewcell the 1st cell. In 1st cell i have a uitableview and 1st cell also has a child of a uitableview delegate/data source with a 2nd cell. Right not I implement a delegate on 1st cell and when the method -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath gets called i pass which cell was selected through the 1st cell delegate method to the view controller to handle any UI changes. Anyway to handle this behavior with blocks? I've been trying to figure that out and implement more blocks through my app and these tutorials have been a huge help!
Kyle
Twitter: @KyleSteelman
- ksteelman
- Uber Haxx0r
- Posts: 52
- Joined: Mon Jan 17, 2011 10:05 pm
- Has thanked: 2 times
- Been thanked: 1 time
Re: How To Use Blocks in iOS 5 Tutorial Part 2
Hello Adam,
thank you for this tutorial.
I got two questions:
Who is the receiver of return in this call?
// Calling that method with a block
- (IBAction)buttonTapped:(id)sender {
[self doMathWithBlock:^(int a, int b) {
return a + b;
}];
}
I'm using ARC and get cyclic retains if I use self.method in a block.
thank you for this tutorial.
I got two questions:
Who is the receiver of return in this call?
// Calling that method with a block
- (IBAction)buttonTapped:(id)sender {
[self doMathWithBlock:^(int a, int b) {
return a + b;
}];
}
I'm using ARC and get cyclic retains if I use self.method in a block.
- zeiteisen
- Uber Haxx0r
- Posts: 70
- Joined: Mon May 02, 2011 8:41 pm
- Has thanked: 5 times
- Been thanked: 4 times
Re: How To Use Blocks in iOS 5 Tutorial Part 2
Excellant tutorial - many thanks!
-

Elliott - Uber Haxx0r
- Posts: 160
- Joined: Sun Jan 02, 2011 10:34 pm
- Location: UK
- Has thanked: 1 time
- Been thanked: 21 times
Re: How To Use Blocks in iOS 5 Tutorial Part 2
mrpills wrote:Hey Adam,
Here is my question I mentioned on twitter.
If the parent view is a viewcontroller that has a child of uitableview and uitableviewcell. we'll call the first uitableviewcell the 1st cell. In 1st cell i have a uitableview and 1st cell also has a child of a uitableview delegate/data source with a 2nd cell. Right not I implement a delegate on 1st cell and when the method -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath gets called i pass which cell was selected through the 1st cell delegate method to the view controller to handle any UI changes. Anyway to handle this behavior with blocks? I've been trying to figure that out and implement more blocks through my app and these tutorials have been a huge help!
Kyle
hmm, I'm still having trouble understanding the relationship.
we'll call the first uitableviewcell the 1st cell. In 1st cell i have a uitableview
Are you saying you have a UITableView inside of a UITableViewCell?
Can you post the code or do you have a sample project you could send?
- acburk
- Forum Subject Matter Expert
- Posts: 389
- Joined: Tue Jul 19, 2011 5:25 pm
- Has thanked: 3 times
- Been thanked: 37 times
Re: How To Use Blocks in iOS 5 Tutorial Part 2
zeiteisen wrote:Hello Adam,
thank you for this tutorial.
I got two questions:
Who is the receiver of return in this call?
// Calling that method with a block
- (IBAction)buttonTapped:(id)sender {
[self doMathWithBlock:^(int a, int b) {
return a + b;
}];
}
I'm using ARC and get cyclic retains if I use self.method in a block.
Hi,
First Question:
The receiver of the return inside the block depends on the implementation of doMathWithBlock. For example if doMathWithBlock was defined as this:
- Code: Select all
- (void)doMathWithBlock:(BOOL(^)(int a, int b))mathBlock {
someVariable = mathBlock(variable1, variable2);
}
So it really depends on how the doMathWithBlock function decides to use that block.
Second Question:
I'm afraid I don't quite understand. I don't see why using (do you mean setting or getting?) the property inside of a block would mess with the retain cycle though. Can you provide more detail? If you are talking about using the 'dot syntax' to get or set a property, you do have to watch out for retain cycles. Look into creating the properties as weak references to help resolve retain cycles with properties and ARC.
- acburk
- Forum Subject Matter Expert
- Posts: 389
- Joined: Tue Jul 19, 2011 5:25 pm
- Has thanked: 3 times
- Been thanked: 37 times
Re: How To Use Blocks in iOS 5 Tutorial Part 2
Thank you Adam I've completed the tutorial, but my question is:
I'm new in Xcode and agree understand all is possible. For example I've a website and I can host a MySQL+PHP database for the foods, but not understand well the relationship with JSON and files of your tutorial.
Can you explain?
I'm new in Xcode and agree understand all is possible. For example I've a website and I can host a MySQL+PHP database for the foods, but not understand well the relationship with JSON and files of your tutorial.
Can you explain?
- gyroanto
- Baby Hacker
- Posts: 5
- Joined: Sun Jan 22, 2012 3:37 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Use Blocks in iOS 5 Tutorial Part 2
Yeah thats exactly what I have. I am trying to detect touches in the pulse tutorial app http://www.raywenderlich.com/4723/how-to-make-an-interface-with-horizontal-tables-like-the-pulse-news-app-part-2 and right now i've just built delegates for the horizontal cell so when a cell is selected from within the tableview in horizontaltableviewcell to pass info back to the view controller
acburk wrote:mrpills wrote:Hey Adam,
Here is my question I mentioned on twitter.
If the parent view is a viewcontroller that has a child of uitableview and uitableviewcell. we'll call the first uitableviewcell the 1st cell. In 1st cell i have a uitableview and 1st cell also has a child of a uitableview delegate/data source with a 2nd cell. Right not I implement a delegate on 1st cell and when the method -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath gets called i pass which cell was selected through the 1st cell delegate method to the view controller to handle any UI changes. Anyway to handle this behavior with blocks? I've been trying to figure that out and implement more blocks through my app and these tutorials have been a huge help!
Kyle
hmm, I'm still having trouble understanding the relationship.we'll call the first uitableviewcell the 1st cell. In 1st cell i have a uitableview
Are you saying you have a UITableView inside of a UITableViewCell?
Can you post the code or do you have a sample project you could send?
Twitter: @KyleSteelman
- ksteelman
- Uber Haxx0r
- Posts: 52
- Joined: Mon Jan 17, 2011 10:05 pm
- Has thanked: 2 times
- Been thanked: 1 time
Re: How To Use Blocks in iOS 5 Tutorial Part 2
JSON is the format that we have chosen to return the data back from the web service to the app, which know how to decode JSON and convert the properties so we can use them.
gyroanto wrote:Thank you Adam I've completed the tutorial, but my question is:
I'm new in Xcode and agree understand all is possible. For example I've a website and I can host a MySQL+PHP database for the foods, but not understand well the relationship with JSON and files of your tutorial.
Can you explain?
- acburk
- Forum Subject Matter Expert
- Posts: 389
- Joined: Tue Jul 19, 2011 5:25 pm
- Has thanked: 3 times
- Been thanked: 37 times
Re: How To Use Blocks in iOS 5 Tutorial Part 2
Thank you Adam.
Interesting Tutorial.
Dario
Interesting Tutorial.
Dario
- fulkron
- n00b
- Posts: 2
- Joined: Mon Dec 19, 2011 6:26 am
- Has thanked: 0 time
- Been thanked: 0 time
27 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: Google [Bot] and 4 guests