我想在我的iPhone 4s上运行一个Swift应用程序.它在模拟器上工作正常,我的朋友可以在他的iPhone 4s上成功运行它.我有iOS 8和Xcode 6的官方发行版.
我试过了
$(inherited) @executable_path/Frameworks以下是整个错误
dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at
address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib
Run Code Online (Sandbox Code Playgroud) 我在Swift中编写了一个简单的表视图应用程序.我试图将图像传递给我的本地节点服务器,并让服务器发回这个接收到的图像,但没有改变它,并将其显示在iPhone屏幕上.嵌入在每个单元格中的是一个启动此帖子/响应处理的按钮.该按钮调用以下功能:
func uploadImage() {
/* Encode UIImage to be passed to server */
let image = UIImage(named: "myImage.png")
let imageData = UIImageJPEGRepresentation(image, 1.0)
let base64String = imageData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.fromRaw(0)!)
var params = ["username":"myUsername", "image": base64String ] as Dictionary
/* Set up request */
let url = NSURL(string: "http://localhost:3000/postRequestHere")
var request = NSMutableURLRequest(URL: url)
var session = NSURLSession.sharedSession()
request.HTTPMethod = "POST"
var err: NSError?
request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: nil, error: &err)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
var task = session.dataTaskWithRequest(request, completionHandler: {data, …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何在后台线程上调度计算,然后更新UI.当我在使用谷歌地图的现有项目中尝试此操作时,"背景"后跟"主"打印一次.不再进行打印,就好像计时器不重复一样.
此外,当我创建一个空白的应用程序并添加此代码时,根本没有任何打印.
let queue = dispatch_queue_create("myTimer", nil);
let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 1 * NSEC_PER_SEC);
dispatch_source_set_event_handler(timer) {
println("background")
dispatch_async(dispatch_get_main_queue(), { println("main") })
}
dispatch_resume(timer)
Run Code Online (Sandbox Code Playgroud)