xcode object-c 类定义、初始化、函数使用

操作系统:mac os 10.8 64

语言:objcect c

开发环境:Xcode4.6

功能:object-c 类定义、初始化、函数使用


Person.h

#import

@interface Person :NSObject

- (BOOL)sendEmailTo:(NSString *)paramTo withSubject:(NSString *)paramSubject andEmailMessage:(NSString *)paramEmailMessage;

@end

Person.m

#import "Person.h"

@implementation Person

- (BOOL)sendEmailTo:(NSString *)paramTo withSubject:(NSString *)paramSubject andEmailMessage:(NSString *)paramEmailMessage

{

    if(paramTo.length ==0 ||

       paramSubject.length ==0 ||

       paramEmailMessage.length ==0)

    {

        NSLog(@"sendemail is null");

       returnNO;

    }

   else

    {

        NSLog(@"send success");

       returnYES;

    }

}

@end


窗体调用类,并执行

#import "DataViewController.h"

#import "Person.h"

@interface DataViewController ()

@end

@implementation DataViewController

- (IBAction)testClassFunction:(id)sender{

   Person *person = [[Person alloc]init];

    [person sendEmailTo:@"[email protected]withSubject:@"123com" andEmailMessage:@"345net"];

}

@end






你可能感兴趣的:(iphone)