我的朋友看到了我的代码,其中一部分是从URL获取plist数据
他告诉我不要使用Synchronous,使用ASynchronous
但我不知道如何以简单的方式进行异步
这是我在程序中使用的代码
NSURL *theURL = [[NSURL alloc]initWithString:@"http://someurllink.php" ];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:theURL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSData *returnData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];
NSString *listFile = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
self.plist = [listFile propertyList];
[self.tableView reloadData];
[listFile autorelease];
Run Code Online (Sandbox Code Playgroud)
如何更改我的代码使用ASynchronous来获取数据?
非常感谢所有回复和答案:)
我有代码1451的mysql错误.
无法删除或更新父行:外键约束失败(
online_store_admin.osa_admin_logs,CONSTRAINTfk_admins_logsFOREIGN KEY(aid)REFERENCESosa_admins(aid))
这里是sql语句:
drop table if exists osa_admins; create table if not exists osa_admins( aid int unsigned not null auto_increment, uid varchar(50) not null, pass char(41) not null, erp_id int unsigned not null, last_login int unsigned not null, is_block tinyint unsigned not null, menus varchar(50) not null, is_login tinyint unsigned not null, ip_login char(15) not null, constraint idx_osa_admins primary key using btree(aid) ); insert into osa_admins value …
我需要能够实现以下方法:
在Mac上,我正在使用XCode,但似乎无法找出执行这些操作的代码.
有人可以帮我从这里出去吗?
谢谢
我正在尝试使用PocketSphinxAndroidDemo项目为Android构建PocketSphinx.我放弃了使用Cygwin和Windows构建它并安装了Ubuntu VM的任务.我正在取得进步,但我似乎陷入困境,我似乎无法弄明白.它必须是我想念的简单事物.ndk-build提供以下输出(剪切):
Compile thumb : pocketsphinx_jni <= pocketsphinx_wrap.c
/home/user/development/PocketSphinxAndroidDemo/jni/pocketsphinx_wrap.c:760:26: error: pocketsphinx.h: No such file or directory
/home/user/development/PocketSphinxAndroidDemo/jni/pocketsphinx_wrap.c:761:28: error: sphinxbase/err.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
头文件(显然)与JNI文件不在同一文件夹中.已在Android.mk文件中设置LOCAL_C_INCLUDES标志以包含所需的标头 -
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android \
$(SPHINX_PATH)/sphinxbase/include/sphinxbase \
$(SPHINX_PATH)/sphinxbase/include \
$(SPHINX_PATH)/pocketsphinx/include
Run Code Online (Sandbox Code Playgroud)
我应该注意,我的SPHINX_PATH变量看起来像这样,而且它是正确的 -
SPHINX_PATH := ~/development
Run Code Online (Sandbox Code Playgroud)
如果我将头文件复制到/ jni /文件夹中,我会更远但是编译器开始对我大喊大叫,因为其他位置缺少头文件.当然我错过了一些简单的东西.是不是在那里我可以设置"在炸毁之前查看头文件的这些位置"标志?
我不是一个C/C++或Linux家伙,所以我在这里不知所措.任何帮助将不胜感激.谢谢!
不幸的是,我没有这方面的大量信息.我有一位客户将他们的网站从古老的系统迁移到Windows 2008 Server上的IIS7.有关错误的信息如下:
错误:E:\ wwwroot\sp\xxx\online_data.xls Microsoft VBScript运行时错误"800a0046"
没有权限
/xxx/oat/exceldata.asp,第52行
码:
49 response.write(server.mappath("online_data.xls"))
50
51 set fso = createobject("scripting.filesystemobject")
52 Set act = fso.CreateTextFile(server.mappath("online_data.xls"), true)
Run Code Online (Sandbox Code Playgroud)
到目前为止唯一的建议是:
授予应用程序池(DefaultAppPool/Classic AppPool)对asp页面所在的物理文件夹的模拟身份读写权限
当我获得访问时会看到这个,但其他建议将不胜感激.
我有一个我本地化的plist.如何正确加载plist?
现在,我正在使用此代码:
NSArray *numbersArray = [[NSArray alloc] initWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"Numbers" ofType:@"plist"]];
Run Code Online (Sandbox Code Playgroud)
为了加载本地化的plist,我需要将代码更改为什么?
任何人都知道为什么下面的代码中的下一个光标没有改变?
cursor = "-1"
followerIds = []
while cursor != 0 do
followers = Twitter.follower_ids("IDTOLOOKUP",{"cursor"=>cursor})
cursor = followers.next_cursor
followerIds+= followers.ids
sleep(2)
end
Run Code Online (Sandbox Code Playgroud)
在第一次迭代,其中cursor = -1,它被分配来自twitter api的nextcursor.但是,当在后续迭代中将其发送到twitter API时,我得到的回复与我第一次使用相同的next_cursor相同.
我有什么想法我做错了吗?我正在使用twitter gem.
如何将md5哈希与grep命令匹配?
在php中我过去使用过这个正则表达式模式:
/^[0-9a-f]{32}$/i
Run Code Online (Sandbox Code Playgroud)
但我试过:
grep '/^[0-9a-f]{32}$/i' filename
grep '[0-9a-f]{32}$/' filename
grep '[0-9a-f]{32}' filename
Run Code Online (Sandbox Code Playgroud)
和其他变种,但我没有得到任何输出,我知道该文件包含md5哈希.
我有动作缓存工作在我的网站索引,并设置一个工作正常的SiteSweeper:
# app/controllers/admin/sites_controller.rb
class Admin::SitesController < Admin::BaseController
cache_sweeper :site_sweeper, :only => [:create, :update, :destroy]
caches_action :index, :cache_path => '/admin/sites'
...
# app/sweepers/site_sweeper.rb
class SiteSweeper < ActionController::Caching::Sweeper
observe Site
def after_save(site)
expire_cache(site)
end
def after_destroy(site)
expire_cache(site)
end
def expire_cache(site)
expire_action '/admin/sites'
end
end
Run Code Online (Sandbox Code Playgroud)
但是,无论何时保存或销毁任何发布者,我也希望过期/管理/站点.是否有可能让PublisherSweeper使用这样的东西使网站索引到期?
# app/sweepers/publisher_sweeper.rb
class PublisherSweeper < ActionController::Caching::Sweeper
observe Publisher
def after_save(publisher)
expire_cache(publisher)
end
def after_destroy(publisher)
expire_cache(publisher)
end
def expire_cache(publisher)
expire_action '/admin/sites'
end
end
Run Code Online (Sandbox Code Playgroud)
我知道我可以在各种Publisher动作中调用expire_action'/ admin/sites'.我只是想知道扫地机是否具备此功能(以保持我的控制器更清洁).
cocoa ×2
ios ×2
android ×1
android-ndk ×1
asp-classic ×1
asynchronous ×1
caching ×1
grep ×1
html ×1
iis-7 ×1
iphone ×1
linux ×1
localization ×1
macos ×1
mysql ×1
objective-c ×1
regex ×1
ruby ×1
shutdown ×1
silverlight ×1
string ×1
sweeper ×1
twitter ×1
xcode ×1