小编Sky*_*ext的帖子

如何在WebView(OSX项目)中启动时加载URL?

我刚刚开始开发mac应用程序,我想在应用程序启动时将WebView作为URL.这是我的代码:

AppDelegate.h

#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>

@interface AppDelegate : NSObject <NSApplicationDelegate> {
     WebView *myWebView;
    //other instance variables
}

@property

(retain, nonatomic) IBOutlet WebView *myWebView;

//other properties and methods

@end
Run Code Online (Sandbox Code Playgroud)

AppDelegate.m:

 #import "AppDelegate.h"
#import <WebKit/WebKit.h>

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSString *urlText = @"http://google.com";
    [[self.myWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
    return;
    // Insert code here to initialize your application
}

@end
Run Code Online (Sandbox Code Playgroud)

如何在WebView(OSX项目)中启动时加载URL?

我认为代码工作,但当我尝试在Interface Builder中将代码与WebView连接时,我无法在插座列表中找到"Web视图".谢谢我在最后一篇文章后更新了我的代码,但仍然无效.再次感谢您的回复.

macos objective-c webview

6
推荐指数
2
解决办法
3万
查看次数

使用Swift 1.2注册Parse用户

我使用Parse.com的注册功能就像这里描述的那样.这是我的代码:

 user.signUpInBackgroundWithBlock {
    (succeeded: Bool!, error: NSError!) -> Void in
    if error == nil {
      // Hooray! Let them use the app now.
    } else {
      let errorString = error.userInfo["error"] as NSString
      // Show the errorString somewhere and let the user try again.
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,我已经将我的项目从swift 1.1更新到swift 1.2并得到以下编译器错误:

函数签名'(Bool!,NSError!) - > void与例外类型'@objc_block(Bool,NSError!) - > Void'不兼容

它在以下行:

user.signUpInBackgroundWithBlock {
        (succeeded: Bool!, error: NSError!) -> Void in
Run Code Online (Sandbox Code Playgroud)

有谁知道我怎么能这样做?谢谢 !

parse-platform swift

2
推荐指数
1
解决办法
798
查看次数

标签 统计

macos ×1

objective-c ×1

parse-platform ×1

swift ×1

webview ×1