1

私は特に客観的なcをプログラミングするのは初めてです。

MainMenu.xib に 2 つのウィンドウがあります。

アプリケーションを実行すると、最初のウィンドウ (webview 付き) が起動します。トップメニューから2番目のウィンドウ(テキストフィールドと保存ボタン付き)を起動できます。

初回起動時のデフォルト URL を「www.google.com」に指定しました。

2番目のウィンドウのテキストフィールドに入れてURLを設定したいと思います。「保存」をクリックするたびに、最初のウィンドウが新しく指定された URL で更新されます。

どのようにそれが可能で、どのようにアクションボタン「SAVE」を接続して、最初のウィンドウに影響を与えることができますか。

これが私のコードです

AppDelegate.h には含まれています

@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet WebView *webview;
@property (assign) IBOutlet NSTextField *urlString;

- (IBAction)save:(id)sender;

@end
**And my AppDelegate.m contains**

@implementation AppDelegate

@synthesize webview;
@synthesize urlString;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

    NSString *urlString = @"http://www.google.com";
    [[webview mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];

}



-(IBAction)save{
[[webview mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString.stringValue]]];

}

@end

ありがとう

4

1 に答える 1