Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Objective - c program help (source included)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="mystic_fm" data-source="post: 773017" data-attributes="member: 28538"><p>Yes, it's okay, although I generally try to avoid it. I was taught that it is better programming form to have exactly one exit point in any function, and I try to do that whenever possible (you may have noticed I arranged things that way in my implementation of the Fibonacci function). However, it is not at all uncommon to see multiple return statements embedded in nested code within a function in order to gain a slight performance improvement, or to simplify the code that follows.</p><p></p><p></p><p></p><p>It sounds like you are on the right track. Don't forget you'd need a pointer to the class as an instance variable in your controller class, e.g.:</p><p></p><p>[CODE]</p><p>#import "fibonacciGenerator.h"</p><p></p><p>@interface appController : NSWindowController {</p><p> fibonacciGenerator *fibGen;</p><p>}</p><p>...</p><p>@implementation appController</p><p>- (id)init</p><p>{</p><p> [super init];</p><p> fibGen = [[fibonacciGenerator alloc] init];</p><p> return self;</p><p>}</p><p>@end</p><p>[/CODE]</p><p></p><p></p><p></p><p>If you mean that you'd create an NSMutableString as an instance member of your controller class, and then append the next sequence value to its contents before making each call to setStringValue for the text area, then yes, that would be a reasonable approach.</p></blockquote><p></p>
[QUOTE="mystic_fm, post: 773017, member: 28538"] Yes, it's okay, although I generally try to avoid it. I was taught that it is better programming form to have exactly one exit point in any function, and I try to do that whenever possible (you may have noticed I arranged things that way in my implementation of the Fibonacci function). However, it is not at all uncommon to see multiple return statements embedded in nested code within a function in order to gain a slight performance improvement, or to simplify the code that follows. It sounds like you are on the right track. Don't forget you'd need a pointer to the class as an instance variable in your controller class, e.g.: [CODE] #import "fibonacciGenerator.h" @interface appController : NSWindowController { fibonacciGenerator *fibGen; } ... @implementation appController - (id)init { [super init]; fibGen = [[fibonacciGenerator alloc] init]; return self; } @end [/CODE] If you mean that you'd create an NSMutableString as an instance member of your controller class, and then append the next sequence value to its contents before making each call to setStringValue for the text area, then yes, that would be a reasonable approach. [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Objective - c program help (source included)
Top