in Education by
Using iOS 5's new TWRequest API, I've ran into a brick wall related with block usage. What I need to do is upon receiving a successful response to a first request, immediately fire another one. On the completion block of the second request, I then notify success or failure of the multi-step operation. Here's roughly what I'm doing: - (void)doRequests { TWRequest* firstRequest = [self createFirstRequest]; [firstRequest performRequestWithHandler:^(NSData* responseData, NSHTTPURLResponse* response, NSError* error) { // Error handling hidden for the sake of brevity... TWRequest* secondRequest = [self createSecondRequest]; [secondRequest performRequestWithHandler:^(NSData* a, NSHTTPURLResponse* b, NSError* c) { // Notify of success or failure - never reaches this far }]; }]; } I am not retaining either of the requests or keeping a reference to them anywhere; it's just fire-and-forget. However, when I run the app, it crashes with EXC_BAD_ACCESS on: [secondRequest performRequestWithHandler:...]; It executes the first request just fine, but when I try to launch a second one with a handler, it crashes. What's wrong with that code? The methods to create the requests are as simple as: - (TWRequest*)createFirstRequest { NSString* target = @"https://api.twitter.com/1/statuses/home_timeline.json"; NSURL* url = [NSURL URLWithString:target]; TWRequest* request = [[TWRequest alloc] initWithURL:url parameters:params requestMethod:TWRequestMethodGET]; // _twitterAccount is the backing ivar for property 'twitterAccount', // a strong & nonatomic property of type ACAccount* request.account = _twitterAccount; return request; } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Make sure you're keeping a reference/retaining the ACAccountStore that owns the ACAccount you are using to sign the TWRequests. If you don't, the ACAccount will become invalid and then you'll get EXC_BAD_ACCESS when trying to fire a TWRequest signed with it.

Related questions

0 votes
    Which one of the following is not considered as one of the building blocks of the model entrepreneur? * a. ... d. personal attributes. Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    My objective-c app needs to be aware if the firewall in OSX is running, so it can tell the user ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I want to get variable value from an objective-c class, using reflection. company.h looks like @interface ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    I'm still trying to understand this piece of code that I found in a project I'm working on where ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    I'm still trying to understand this piece of code that I found in a project I'm working on where ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I wanted to create a gallery. It loads different images based on the category, that a user selects. I used to populate ... ; int imgCount = [galleryImages count]; for(int i=0;i...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I'm making a 'post text' app and trying to update my database with name and body field. The obj-c code looks like this: ... (@"%@", strResult); } And the php code looks like this:...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    Can we use both swift (.swft) and objective c (.h .m) in same xcode project ?...
asked Mar 9, 2021 in Technology by JackTerrance
0 votes
    How do I call Objective-C code from Swift?...
asked Mar 9, 2021 in Technology by JackTerrance
0 votes
    Explain the difference between Swift vs Objective-C.?...
asked Nov 30, 2020 in Technology by JackTerrance
0 votes
    What are benefits of collections views in Objective-C?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    How we can layout subviews in a view in Objective-C?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    What are the size classes in Objective-c?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    Why create a custom view in Objective-C?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    What is bundle in Objective-c?...
asked Nov 10, 2020 in Technology by JackTerrance
...