我需要在加载webview中的任何url时检查响应状态代码.现在我们可以考虑在web视图中加载的任何Web应用程序.所以我需要跟踪具有该webview的每个请求并相应地检查响应代码.为了找到响应代码,我需要在uiwebview的委托方法"shouldStartLoadWithrequest"中使用NSUrlConnection.有点像这样 -
- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType{
NSURLConnection *conn = [NSURLConnection connectionWithRequest:request delegate:self];
if (conn == nil) {
NSLog(@"cannot create connection");
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
和NSURLConnectionDelegate一样 -
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
NSLog(@"connection:didReceiveResponse");
[self log:@"received response."];
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
int status = [httpResponse statusCode];
NSLog(@"http status code: %d", status);
if (status == 200) {
NSLog(@"Response OK");
}
else {
NSLog(@"Response is not OK");
}
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
NSLog(@"connection:didReceiveData");
}
- …Run Code Online (Sandbox Code Playgroud) iphone uiwebview ios uiwebviewdelegate nsurlconnectiondelegate
如果没有记录存在,我需要向表中添加一些记录。现在,我已经编写了在 sequelize.sync({force:true}) 的回调函数中添加记录的逻辑。我已经检查了该表是否包含至少一条记录,如果没有,我已经插入了一组记录。有没有其他优雅的方式来获得这个功能?
构造函数功能在 PHP 7.0.x 中已弃用,那么我如何以其他方式使用或访问此变量?任何人都可以有想法吗?请帮助我找到正确的解决方案...
例如:
public function __construct() {
$this->user = new User();;
}
Run Code Online (Sandbox Code Playgroud)
我们如何定义这个?
ios ×2
iphone ×2
android ×1
mask ×1
node.js ×1
php ×1
php-7 ×1
sequelize.js ×1
uiimageview ×1
uiwebview ×1