Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 585269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:59:07+00:00 2026-05-13T14:59:07+00:00

I am writing a simple application using the Facebook iPhone SDK. The Facebook code

  • 0

I am writing a simple application using the Facebook iPhone SDK. The Facebook code is mostly asynchronous, I start an operation and receive the response asynchronously in a delegate call:

- (void) doSomething {
    [FBSomething startOperationWithDelegate:self];
}

- (void) fbOperationFinished: (FBSomething*) operation {…}

Quite often there are more instances of a given operation (say FBRequest) that use the same callback. This means that I have to put a conditional clause into the callback handler to know which of these operations finished.

This leads to messy, a kind of “asynchronous spaghetti code” monster because the code is full of conditionals and it’s almost impossible to see the program flow logic. Is there a better way to write such code? (It’s a shame we don’t have blocks on iPhone.) I thought about introducing a simple state machine, but I’m not sure it will help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:59:07+00:00Added an answer on May 13, 2026 at 2:59 pm

    I’m not familiar with the Facebook SDK, but you could just create a subclass that implements the FBRequestDelegate protocol (if it’s called like that) for every specific task you need Facebook for. This way, you have say 5 classes implementing - fbOperationFinished: rather than one class with 5 different execution paths separated by ifs or switches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you're writing a simple database web application using Ruby and MySQL. Access to
I'm writing simple GUI using wxPyhon and faced some problems. My application does simple
I am writing a very simple application, for the iPhone. Unfortunately I am really
I'm Writing a facebook application using the Java-facebook-api and MySQL 5.1. I'm trying to
I'm writing a simple web application using CakePHP version 1.2 (the latest) and am
I'm writing fairly simple application which connects to server through SSH (using paramiko ),
I'm writing a simple P2P application to test the feasibilty of using UDP hole-punching
I'm writing a simple client/server application and I found that using DataInputStream to read
I am writing a simple application and am using glade (gtk) for the UI.
I'm writing a simple application using EXT-JS 4.0 for creating quick surveys. The questions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.