#import <Foundation/Foundation.h>
@interface Bird:NSObject
{
    
    
}- (void) eat;
- (void) sleep;@end@implementation Bird    -(void)eat
    {
        NSLog(@"吃的方法");
    }    -(void)sleep
    {
        NSLog(@"睡的方法");
    }@endint main(int argc, const char * argv[])
{
    //@autoreleasepool {  
        
    // insert code here...
    NSLog(@"Hello, World!");
    id b[0];
    b[0]=[Bird new];
    [b[0] eat];
    //
    
    return 0;
}
程序无法调用eat方法,提示break point求大神指教

解决方案 »

  1.   

    这种写法太奇怪了。id b[0];这就有问题,声明一个id类型的数组,该数组含有0个元素?
      

  2.   

    Bird *bird = [[Bird alloc] init];
    [bird eat];
    [bird release];
      

  3.   

    先找本objective-c的书看看吧。
      

  4.   

    oc是用alloc init来构造实例对象。这点和java有些不同。
    break point是断点的问题,不是错误。