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 7061415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:28:16+00:00 2026-05-28T04:28:16+00:00

I have a method to construct a post request. That request may have x

  • 0

I have a method to construct a post request. That request may have x number of parameters but none of them are mandatory. There are parameters of type boolean (those are passed as strings with values “true” or “false” (not my decision, it is an API).

Here is the problem. My method declaration contains all the parameters that are accepted as part of the post request. The problem is that the request returns different results if a boolean parameter is true, is false or it is not present.

My method id something like

-(void) createRequestWithID:(NSString *)id translate(NSNumber *)translate onlyLastVersions:(NSNumber *)onlyLastVersions

My method is part of a framework which will be used and called by other developers. That means, I cannot control what they pass to parameters such as translate which is a boolean (I use NSNumber as wrapper).

And here comes the problem. I need to be able to identify if the method was called pasing translate as true, false or nil. Because for those cases, I will have the request as translate=”true”, translate=”false” or translate will be not present in the request.

I need a way to differentiate between true, false and nil.

Testing on gbd to try to find a way to differenciate it I get:

(gdb) p translateFALSE
$5 = (NSNumber *) 0x0

(gdb) p translateNIL
$6 = (NSNumber *) 0x0

(gdb) po translateFALSE
Can’t print the description of a NIL object.

(gdb) po translateNIL
Can’t print the description of a NIL object.

(gdb) po [translateFALSE class]
Can’t print the description of a NIL object.

(gdb) po [translateNIL class]
Can’t print the description of a NIL object.

So I see no way to do it.

  • 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-28T04:28:17+00:00Added an answer on May 28, 2026 at 4:28 am
    if( translate ) {
      if( [translate boolValue] ) {
        // translate is present and is set (YES)
      } else {
        // translate is present and is not set (NO)
      }
    } else {
      // translate is nil / not present
    }
    

    If you prefer to have this look more like a three-way branch:

    if( [translate boolValue] ) {
      // translate is present and is set (YES)
    } else if( translate ) {
      // translate is present and is not set (NO)
    } else {
      // translate is nil / not present
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a service contract that defines a method with a parameter of type
I have read several of the post about Objective-C method syntax but I guess
I have a method fetchObjects(String) that is expected to return an array of Contract
I have a BO method that must do two operations to fulfill its contract.
I have a basicHttpBinding WCF service. Via the contract I expose a method that
I have method in a class that I need to make sure is only
I have class method that returns a list of employees that I can iterate
I have a method that where I want to redirect the user back to
Let's say I have a blog application. On each Post there are Comments. So,
** Update I have a solution below, but it's rather manual... if there is

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.