Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Apple Software > Mac Programming
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 24, 2009, 09:35 PM   #1
knott
macrumors newbie
 
Join Date: Nov 2009
Hello world help

Hi all, i am new. i have a button A and want to call function B that returns the message "hello".
Can you please help me, Thank you

hello.h
PHP Code:
#import <Cocoa/Cocoa.h>

@interface hello NSObject {
    
IBOutlet NSTextView *msg;
}
- (
IBAction)button:(id)sender;
@
end 
hello.m
PHP Code:
#import "hello.h"

@implementation hello

- (IBAction)button:(id)sender {
--- 
what should come here? ---
}

- (--- 
what should come here? ---) {
NSMutableString *msg = [[NSMutableString allocinit];
NSString *str = [NSString stringWithFormat:@"hello"];
[
msg appendString:str];
return [
msg autorelease];
}

@
end 
knott is offline   Reply With Quote
Old Nov 24, 2009, 10:59 PM   #2
kainjow
Demi-God (Moderator)
 
kainjow's Avatar
 
Join Date: Jun 2000
You can name your method whatever you want. Maybe call it "helloText". Using that example, you would first need to declare it in your header file as such:
Code:
- (NSString *)helloText;
Then, plug that into the implementation file:
Code:
- (NSString *)helloText
{
    ... blah blah ...
}
To call it, use:
Code:
[self helloText];
If you want to put the method's returned value into your text view, use:
Code:
[msg setString:[self helloText]];
kainjow is offline   Reply With Quote
Old Nov 25, 2009, 11:44 AM   #3
knott
Thread Starter
macrumors newbie
 
Join Date: Nov 2009
Thank you for your help!
knott is offline   Reply With Quote

Reply

Mac Forums > Apple Software > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:41 PM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 2002-2010, MacRumors.com, LLC