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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:05:13+00:00 2026-06-05T07:05:13+00:00

I have a model object that represents a triangle. There are a handful of

  • 0

I have a model object that represents a triangle. There are a handful of init methods taking different combinations of parameters that are known. Then it solves for the remaining values (lengths of sides and angles). Currently I have the initializer return nil if the given parameters are nil or out of proper ranges for this triangle type. However to give proper feedback to the user the controller object has to also check for improper input values like angle > 90 deg and the like. This stinks to me as these rules should be defined once in just the model. So my thought is to have an NSError object that gets set to string that the controller should show to the user. I’m just not sure the best way to convey this to the controller. Should my init method return this NSError instead of the Triangle instance if an error occurs? This seems wrong. Or do I pass a pointer to the NSError object as a parameter to the init, and populate it if an error occurs? If I do this do I still return nil from the init for the triangle object since its unusable or do I just partially init the triangle and return that?

  • 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-06-05T07:05:14+00:00Added an answer on June 5, 2026 at 7:05 am

    You should follow the same convention that other Cocoa objects use, as described in Apple’s Error Handling Programming Guide:

    • Add a parameter that takes an NSError** as the last parameter to the method.
    • Upon an error, if that parameter is not NULL, populate it with an NSError object and return nil.
    • In the case of an init method, you should also [self release] before returning nil (unless you’re using ARC).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using EF Code First I have an model object that has multiple properties that
Okay here is what I'm trying to do: I have a model object that
I have an object model that contains several lists of other objects. I want
I have a Sinatra/Mongoid application and I noticed that my mongoid model/object does not
I have very newbie question. How can i check that object of model is
I have a model with some fields. I have a model form that represents
If I have a model that essentially represents a single row in a database,
I have written a checkers game model which has a Board object that holds
I have an object that represents a food item to order at a restaurant.
I have a belonging model that allows user to post objects to be sold

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.