私はTableViewControllerを作ろうとしています..YouTubeのレッスン「Cocoa Programming L13-14」のコードを使用して動作させましたが、デフォルト値がハードコーディングされないように変更しようとすると...しかしInterface Builder のコントロールの値ではなく、全面的に (null) を取得します。コードは次のとおりです。
#import <Foundation/Foundation.h>
@interface Person : NSObject {
IBOutlet NSPathControl* pcSource;
IBOutlet NSPathControl* pcDestination;
IBOutlet NSTextField* tfBackupAmount;
NSURL* urlSource;
NSURL* urlDestination;
NSString* strBackupAmount;
//Old--
//NSString* name;
//int age;
}
@property NSURL* urlSource;
@property NSURL* urlDestination;
@property NSString* strBackupAmount;
//Old--
//@property (copy) NSString* name;
//@property int age;
@end
と
#import "Person.h"
@implementation Person
@synthesize urlSource;
@synthesize urlDestination;
@synthesize strBackupAmount;
//Old--
//@synthesize name;
//@synthesize age;
- (id)init {
self = [super init];
if (self) {
urlSource = [pcSource URL];
urlDestination = [pcDestination URL];
strBackupAmount = [tfBackupAmount stringValue];
NSLog(@"%@\n%@\n%@",urlSource,urlDestination,strBackupAmount);
//Old--
//name = @"Yoda";
//age = 900;
//NSLog(@"%@: %i", name, age);
}
return self;
}
@end
コメントされたすべての //Old-- が機能し、TableViewController と正常にやり取りしました。したがって、すべてがまだ正常に機能していると思います。3 つのコントロール (2 つの NSPathControl と 1 つの NSTextField) は、コントロールがリンクされた Interface Builder の Object クラス:Person にリンクされています。次の出力が得られるのはなぜですか:
(null)
(null)
(null)
? NSLog(); に到達したとき。ライン?どこが間違っていますか?ありがとう!