PrefMySpotsViewCtrl.h
@class Location;
@interface PrefMySpotsViewCtrl : NSViewController
{
NSTextField *locationSearchInput;
NSString * enteredLocation;
Location *l;
}
@property (nonatomic, retain) IBOutlet NSTextField *locationSearchInput;
@property (nonatomic, retain) NSString *enteredLocation;
PrefMySpotsViewCtrl.m
#import "Location.h"
- (void) controlTextDidChange:(NSNotification *)aNotification
{
enteredLocation = [locationSearchInput stringValue];
NSLog(@"in class:%@", enteredLocation);
[l searchLocation];
}
Location.h
@class PrefMySpotsViewCtrl;
@interface Location : NSObject
{
PrefMySpotsViewCtrl *p;
}
- (void) searchLocation;
Location.m
#import "Location.h"
#import "PrefMySpotsViewCtrl.h"
@implementation Location
- (void) searchLocation
{
NSLog(@"out of class: %@", [p enteredLocation]);
}
ユーザーが a を入力するlocationSearchInput
と、ここに出力が表示されます
2012-09-30 10:18:12.915 MyApp[839:303] in class:
2012-09-30 10:18:12.917 MyApp[839:303] in class:a
searchLocation
メソッドは実行されません。
もしそうならl = [[Location alloc] init];
、searchLocation
実行されますが、出力はnull
2012-09-30 10:28:46.928 MyApp[880:303] in class:
2012-09-30 10:28:46.929 MyApp[880:303] out of class: (null)
2012-09-30 10:28:46.930 MyApp[880:303] in class:a
2012-09-30 10:28:46.931 MyApp[880:303] out of class: (null)
何か案が?
ありがとう?