逛奔的蜗牛

我不聪明,但我会很努力

   ::  :: 新随笔 ::  ::  :: 管理 ::

-(id) init {

    [self dealloc];

    @throw [NSException exceptionWithName:@"BadInitCall" 

                                   reason:@"The class must initialized with initWithEntryDate" 

                                 userInfo:nil];

    return nil;

}


-(id) initWithEntryDate:(NSCalendarDate*)newEntryDate {

    self = [super init];

    

    if (self == nil) {

        return nil;

    }

    

    [self setEntryDate:newEntryDate];

    [self prepareRandomNumber];

    

    return self;

}

#import <Foundation/Foundation.h>

#import "LotteryEntry.h"

int main (int argc, const char * argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    LotteryEntry* lotter;

    @try {

        lotter = [[LotteryEntry alloc] init];

    } @catch (NSException * e) {

        NSLog(@"%@", [e reason]);

    } @finally {      

    }   

    [lotter release];

    lotter = [[LotteryEntry alloc] initWithEntryDate:[NSCalendarDate calendarDate]];

    [lotter release];

    [pool drain];

    return 0;

}


 

posted on 2008-10-03 03:56 逛奔的蜗牛 阅读(210) 评论(0)  编辑 收藏 引用 所属分类: C/C++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理