我正在使用带有PHP和一些Javascript的websockets.我将数据库中的一些信息显示给我的客户端.我的目标是在信息插入我的数据库时刷新客户端.要在我的数据库中插入一些数据,我从我的PC发送一个帖子请求.
此刻,我可以刷新客户端每10秒调用一次函数.但是,只有在该页面上发送POST请求时,我才想刷新.
这可以帮助您理解:

这就是我所做的:
index.php(显示信息的页面)
$(document).ready(function(){
//create a new WebSocket object.
var wsUri = "ws://localhost:9000/server.php";
websocket = new WebSocket(wsUri);
websocket.onopen = function(ev) { // connection is open
$('#message_box').append("<div class=\"system_msg\">Connected!</div>"); //notify user
}
// Call this function every 10 sec to refresh the client
window.setInterval(function(){
displayInfo(1);
}, 10000);
websocket.onmessage = function(ev) {
var msg = JSON.parse(ev.data); //PHP sends Json data
$("#infos").html(msg.message);
};
websocket.onerror = function(ev){$('#message_box').append("<div class=\"system_error\">Error Occurred - "+ev.data+"</div>");};
websocket.onclose = function(ev){$('#message_box').append("<div class=\"system_msg\">Connection Closed</div>");}; …Run Code Online (Sandbox Code Playgroud)我希望你一切都好:)
我有一个使用 Core Data 的数据库。在我的应用程序 V1.0 中,用户可以在应用程序中导入一些文件。现在,对于我的 V2.0,我想在我的模型中添加一个属性,但是拥有 V1.0 并且有一些存储文件的用户必须保存所有文件(如果他们升级应用程序,则不会删除......) . 因此,我创建了一个具有新属性的新数据模型,并将当前版本化的核心数据模型设置为我的新数据模型……好的。但是如果启动我的应用程序,该文件将被删除。
通常,我必须使用映射模型。但是怎么做呢?创建映射模型时,源数据模型和目标数据模型是哪个?
非常感谢你的帮助!祝大家有个美好的一天!:)
编辑:
如果我只添加一个新属性而不编辑属性的名称,也许我不需要创建映射模型...不是吗?
我正在使用我的应用程序导入一些PDF文件.但我正试图在我的数据库中插入我的PDF文件.我正在使用核心数据.是否有可能做到这一点 ?如果是,我该怎么办?我必须使用哪种类型(NSData,NSDocument,......?)
非常感谢!:)
我正在尝试手动更新magento中的库存数量。我知道有可能,但我不知道如何进行...
我想通过Web服务更新库存,我正在搜索如何列出所有文章。然后,获取商品的ID,将其发送到Web服务,获取Web服务提供的库存,最后,更新Magento数据库中的库存。
我是Magento的新用户,非常感谢您的帮助:)
十分感谢大家!
我有一个mapview数百个注释.我在后台加载注释,当加载所有注释时,我调用方法:setAnnotations.
我有6种类型的注释,彼此不同的引脚.
它适用于第一次装载.但是如果我想刷新地图(因为我使用过滤器),则图像图像会发生变化.
我在这里看到了类似的问题,但似乎对我不起作用.
这里是我的viewForAnnotation方法:
//...
else if ([annotation isKindOfClass:[CustomAnnotation class]]) {
CustomAnnotation *singleAnnotation = (CustomAnnotation *)annotation;
annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"singleAnnotationView"];
if (!annotationView) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:singleAnnotation reuseIdentifier:@"singleAnnotationView"];
annotationView.canShowCallout = YES;
annotationView.centerOffset = CGPointMake(0, -20);
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
else
annotationView.annotation = annotation;
// Solution, put it here:
annotationView.image = [UIImage imageNamed:[NSString stringWithFormat:@"pin_%d", singleAnnotation.idType]];
}
//...
Run Code Online (Sandbox Code Playgroud)
在这里我调用加载和重新加载地图的方法:
- (void)loadMapView
{
UIActivityIndicatorView *a = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
self.mapview.hidden = YES;
a.center = CGPointMake(160, 240);
[self.view …Run Code Online (Sandbox Code Playgroud) 我有一个带有titleLabel的UIButton,例如,像这样: @"Download it!"
我想在下载完成后,用另一个文本更新我的按钮的titleLabel,例如,像这样: @"Already downloaded!"
我可以更改状态(启用或不启用),但无法刷新/更新UIButton的titleLabel.
知道怎么做吗?我试过[myButton setNeedsDisplay];但它不起作用.
感谢您的建议和帮助.
更新1: 解决方案:
[yourButton setTitle:<#(NSString *)#> forState:<#(UIControlState)#>]
Run Code Online (Sandbox Code Playgroud) 我有一个来自我的数据库的名单.
我正在尝试转换PDO :: fetchAll()函数的结果,以获得类似字符串的结果:
"name1","name2","name3"等
我不知道你是否知道我的意思.
感谢大家的帮助!