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
Cocoa... custom class executes own method....? Help
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: 788142" data-attributes="member: 28538"><p>If you are trying to call this "custom method" from another method in the same class instance, then [self method] compiles and runs fine for me, as seen in the code below:</p><p></p><p>[code]</p><p>AppController.h:</p><p>@interface AppController : NSObject</p><p>{</p><p> /* unrelated class details omitted for brevity */</p><p>}</p><p>- (NSString *) getText; /* this is the method */</p><p>@end</p><p></p><p>AppController.m:</p><p>@implementation AppController</p><p>- (id) init</p><p>{</p><p> [super init];</p><p> NSString *newText = [self getText];</p><p> NSLog(@"%@", newText);</p><p> return self;</p><p>}</p><p></p><p>- (NSString *) getText</p><p>{</p><p> static int i = 0;</p><p> return [NSString stringWithFormat:@"%d calls to getText", i++];</p><p>}</p><p>@end</p><p>[/code]</p><p></p><p>Otherwise, you'll need to provide more details as to what you are trying to accomplish and from where.</p></blockquote><p></p>
[QUOTE="mystic_fm, post: 788142, member: 28538"] If you are trying to call this "custom method" from another method in the same class instance, then [self method] compiles and runs fine for me, as seen in the code below: [code] AppController.h: @interface AppController : NSObject { /* unrelated class details omitted for brevity */ } - (NSString *) getText; /* this is the method */ @end AppController.m: @implementation AppController - (id) init { [super init]; NSString *newText = [self getText]; NSLog(@"%@", newText); return self; } - (NSString *) getText { static int i = 0; return [NSString stringWithFormat:@"%d calls to getText", i++]; } @end [/code] Otherwise, you'll need to provide more details as to what you are trying to accomplish and from where. [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Cocoa... custom class executes own method....? Help
Top