2012-11-24 16 views
1

我是新來的ios編程和卡在我的第二個教程,它調用了你的第二個iOS應用程序,關於在apple.apple.com 。在'運行代碼時'顯示詳細信息場景中的信息'部分的結尾處,我得到「不可見的@ birdfaceing接口」在BirdSightingDataController.m文件中聲明瞭選擇器'initwithname:location:date:'「錯誤「目擊= [[BirdSighting alloc] initWithName:@」Pigeon「位置:@」Everywhere「date:today];」線。我檢查了很多次這個文件,並再次做了這個測試,但是我不知道該如何糾正這個問題?不可見@interface對於'鳥ighting'聲明選擇器'initwithname:location:date:'

#import "BirdSightingDataController.h" 
#import "BirdSighting.h" 
@interface BirdSightingDataController() 
- (void)initializeDefaultDataList; 
@end 
@implementation BirdSightingDataController 
- (void)initializeDefaultDataList { 
    NSMutableArray *sightingList = [[NSMutableArray alloc] init]; 
    self.masterBirdSightingList = sightingList; 
    BirdSighting *sighting; 
    NSDate *today = [NSDate date]; 
    sighting = [[BirdSighting alloc] initWithName:@"Pigeon" location:@"Everywhere" date:today]; 
    [self addBirdSightingWithSighting:sighting]; 
} 
- (void)setMasterBirdSightingList:(NSMutableArray *)newList { 
    if (_masterBirdSightingList != newList) { 
     _masterBirdSightingList = [newList mutableCopy]; 
    } 
} 
- (id)init { 
    if (self = [super init]) { 
     [self initializeDefaultDataList]; 
     return self; 
    } 
    return nil; 
} 
- (NSUInteger)countOfList { 
    return [self.masterBirdSightingList count]; 
} 
- (BirdSighting *)objectInListAtIndex:(NSUInteger)theIndex { 
    return [self.masterBirdSightingList objectAtIndex:theIndex]; 
} 
- (void)addBirdSightingWithSighting:(BirdSighting *)sighting { 
    [self.masterBirdSightingList addObject:sighting]; 
} 
@end 

Birdsighting.h文件

#import <Foundation/Foundation.h> 

@interface BirdSighting : NSObject 

@property (nonatomic, copy) NSString *name; 
@property (nonatomic, copy) NSString *location; 
@property (nonatomic, strong) NSDate *date; 
-(id)initWithName:(NSString *) name locaiton:(NSString *)location date:(NSDate *) date; 

@end 
+0

不錯,你可以在你的BirdSightingDataController代碼中複製這個問題,但是你應該複製到這裏的是你的BirdSighting.h文件的內容。你很可能錯過了「'initWithName:location:date:'」方法聲明(也可能是實現)。 –

回答

0

檢查Birdsighting.h並確保該方法

- (id)initWithName:(NSString *)name location:(NSString *)location date:(NSDate *)date; 

聲明那裏。這基本上告訴其他類什麼方法可用於Bidsighting類的實例。

其可能存在接口聲明中的拼寫錯誤(即使在蘋果示例中也會發生這種錯誤)。

+0

添加BirdSighting.h文件 – user1849505

+0

locaiton拼寫不正確:) –

+0

現在它的工作謝謝,我的壞: – user1849505

相關問題