Tag: nsurl

+ 返回零

我使用这个代码从URL加载UIImage : NSURL *imageURL = [NSURL URLWithString:@"http://testwebsite.com/image.png"]; NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL]; imageView.image = [UIImage imageWithData: imageData]; 但我被卡在一个像这样的URL : http://www.testwebsite.com/getFile?userID=123 这在浏览器中正常工作,但在上面的imageDatavariables中返回nil。 我怎么能从这样一个模糊的URL加载图像(即从不显示文件名,而是redirect到图像文件的URL )? 先谢谢你。

containerURLForSecurityApplicationGroupIdentifier获取零值

我正在制作两个iPad应用程序与一个文件进行通信,并从一个文件中提取所有数据。 我search并find这个“containerURLForSecurityApplicationGroupIdentifier”我们可以创build组和存储在那。 我已经写下面的代码。 在权利文件我写 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.application-groups</key> <array> <string>$(TeamIdentifierPrefix)com.xxx.catalogapp.Coredata</string> </array> <key>keychain-access-groups</key> <array> <string>$(AppIdentifierPrefix)com.xxx.catalogapp.Coredata</string> </array> </dict> </plist> 而在代码我写这个 NSFileManager* fileManager = [NSFileManager defaultManager]; NSURL* storeUrl = [fileManager containerURLForSecurityApplicationGroupIdentifier:@"com.xxx.catalogapp.Coredata"]; NSLog(@"%@", storeUrl); 但是storeUrl我nil价值。

Alamofire错误代码= -1000“URL不指向文件URL”

有问题从我正在开发的iOS应用程序上传图像到我的服务器。 我正在使用Alamofire和一个UIImagePickerController 。 在didFinishPickingMediaWithInfo委托方法内我保存用户从名为self.imageNSURL的variables中的info[UIImagePickerControllerReferenceURL]select作为NSURL的文件。 通过这个Alamofires上传multipartFormData方法(几乎是从他们的文档标准复制和粘贴) Alamofire.upload( .POST, URLString: "http://app.staging.acme.com/api/users/\(id)/picture", multipartFormData: { multipartFormData in multipartFormData.appendBodyPart(fileURL: self.imageNSURL, name: "image") }, encodingCompletion: { encodingResult in switch encodingResult { case .Success(let upload, _, _): upload.responseJSON { request, response, JSON, error in println(JSON) } case .Failure(let encodingError): println(encodingError) } } ) 我得到的错误是 Error Domain=com.alamofire.error Code=-1000 "The operation couldn't be completed. […]

iOS:播放需要validation的video在QuickLook中播放,但不在MPMoviePlayerViewController中播放

我使用SOAP web servicelogin到我的服务器。 login后,我正在查看的许多文件只能用于login用户,所以iOS必须在NSURL创build会话或其他内容。 当试图使用MPMoviePlayerViewController预览video文件时,它不会工作,它只是加载viewController,然后解散它。 如果我使用QuickLook它可以工作,可能是因为我先在本地下载video,然后查看它。 但是,我不想这样做,我想使用MPMoviePlayerViewControllerstreamvideo,因为我不希望用户不得不下载整个video文件。 我已经看到有关使用NSURLCredentialpost,但这似乎不适用于我。 我使用(显然添加了我自己的个人信息): /** * Play media session * * @version $Revision: 0.1 */ – (void)playMediaWithURL:(NSString *)mediaURL { // Authenticate NSURLCredential *credential = [NSURLCredential credentialWithUser:@"myusername" password:@"mypassword" persistence:NSURLCredentialPersistenceForSession]; NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:@"mysite.com" port:80 protocol:@"http" realm:nil authenticationMethod:NSURLAuthenticationMethodDefault]; [[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential forProtectionSpace:protectionSpace]; // The movie player NSURL *movieURL = [NSURL […]

Swift – 从iOS PHAsset播放video

我想从PHAsset播放来自iOS照片的video。 PHAssetvideonsurl ( https://stackoverflow.com/a/35099857/1084174 )是有效的我自己的应用程序可以说MyPlayer的片刻/块。 当我将图像/video复制到MyPlayers自己的沙盒中时, nsurl总是有效的。 在我看来, 我需要将每个video从临时PHAsset复制到MyPlayers沙盒(appgroup / documents),然后才能使用沙盒相关nsurl播放video。 如果是这样,所有其他玩家如何在飞行中播放长video? 如果有其他方式播放video而不复制到应用程序沙盒,请让我知道的方式。

NSURL isFileURL总是返回NO

有人可以向我解释为什么下面的代码: NSString* filePathString = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSLog(@"%i", [[NSURL URLWithString:filePathString] isFileURL]); NSLog(@"%@", filePathString); 输出: 0 “在/ var /移动/应用/ 28ADFC19-874C-4304-94B5-F6441CAE9FAD /文档” 这意味着这个URL不是一个文件的URL。 显然是这样。 背景: 我正在尝试使用AVCaptureMovieFileOutput将影片录制到文件中,但是我certificate的文件url给出了错误: *由于未捕获exception'NSInvalidArgumentException',原因:'* – [AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] – 无法logging到URL / var / mobile / Applications / 28ADFC19-874C-4304-94B5-F6441CAE9FAD / Documents / media / CrKNjNhe9so2LRnD9iHK .mov,因为它不是一个文件的URL。 就像原来的例子,这看起来像一个文件的URL。 是什么赋予了?

MPMoviePlayerController不能从Documents文件夹中播放

Desperated。 大家好! 我有一些与MPMoviePlayerController问题。 我已经使用NSBundle的video。 但那不是我所需要的。 我需要从Documents目录播放它,因为那是我存储录制video的地方,这些URL存储在CoreData中。 但是让我们把它放在一边,简化代码到最小的需要。 这个代码实际上是工作如果使用contentURL,导致NSBundle。 之后,我做了什么去文档的地方。 我做的事: NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"Oct_08_2012_10_00_51" withExtension:@"mp4"]; // this works NSString* docPath = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString * docaPathFull = [NSString stringWithFormat:@"%@%@", docPath, @"/Oct_08_2012_10_00_51.mp4"]; NSURL * docUrl= [NSURL URLWithString: docaPathFull]; BOOL ex = [[NSFileManager defaultManager] fileExistsAtPath:docaPathFull]; NSLog(@"file exists: %d, path using docPath: %@",ex, […]

从Facebook的任何url获取特定的图像

我的问题看起来可能与其他问题类似,但事实并非如此(据我所知)。 我不明白,如何从任何url获取特定的图像像Facebook一样,我不能给你看屏幕截图,因为我没有真正的设备。 但是我可以向你展示Skype的MAC屏幕截图。 任何帮助将不胜感激。 谢谢。 编辑: 我得到了使用这个链接的图标,但它是非常小的,我希望在更大的尺寸。

iOS Swift。 如何从一个UIImage(NSURL)获取GPS元数据?

参考一个只有NSURL的图片。 如何从中获取GPS元数据? 当然,我可以从NSURL加载一个UIImage,但是什么? 我在这里find的大部分答案是关于UIImagePicker,然后使用ALAssets,但是我没有这个选项。

如何从URLscheme中获取参数。

我在我的iPhone应用程序中使用URLscheme,从切换用户到Safari浏览器的页面,以及从Web页面点击一个button,我将恢复到应用程序当时,一些参数通过网页传递 myapp://parameter=1 我如何从我的应用程序中find这个参数? 我已经放了一个断点 -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)ur 但是,当回复,它不被调用。