小编Mik*_*lah的帖子

什么是NSURL*resultURL通过Facebook iOS SDK邀请朋友?

我正在开发一款iOS游戏,它将使用Facebook请求作为用户获取策略的一部分.我已经实现了请求对话框,并且已经可以向我的朋友发送请求了.在Facebook的iOS版SDK的回调函数返回3个对象:FBWebDialogResult result,NSURL *resultURLNSError *error

我怀疑的是NSURL,它具有以下格式:

fbconnect://success?request=23269054024361&to%5B0%5D=1453458133453.

我该怎么办这个网址?我看到它是一个传递最近邀请的朋友ID的URL.

sdk facebook ios

3
推荐指数
1
解决办法
669
查看次数

iOS AFNetworking downloadProgressBlock计算返回负数

我正在使用AFNetworking下载使用第三方类解析的数据.我曾经多次使用AFNetworking做类似的动作,但出于某种原因,当我调用downloadProgressBlock并进行计算以使用我的进度条时,数字会返回负数.见下文:

2013-09-22 16:04:06.036 Portland Police[2228:60b] Download = -31849.000000
2013-09-22 16:04:06.041 Portland Police[2228:60b] Download = -40537.000000
2013-09-22 16:04:06.042 Portland Police[2228:60b] Download = -44881.000000
2013-09-22 16:04:06.044 Portland Police[2228:60b] Download = -53569.000000
2013-09-22 16:04:06.046 Portland Police[2228:60b] Download = -62257.000000
2013-09-22 16:04:06.048 Portland Police[2228:60b] Download = -63705.000000
2013-09-22 16:04:06.085 Portland Police[2228:60b] Download = -70945.000000
2013-09-22 16:04:06.087 Portland Police[2228:60b] Download = -89769.000000
2013-09-22 16:04:06.089 Portland Police[2228:60b] Download = -94113.000000
2013-09-22 16:04:06.100 Portland Police[2228:60b] Download = -98457.000000
2013-09-22 16:04:06.104 Portland Police[2228:60b] Download = -102801.000000
2013-09-22 16:04:06.111 …
Run Code Online (Sandbox Code Playgroud)

ios afnetworking progress-bar afhttprequestoperation

3
推荐指数
1
解决办法
3280
查看次数

Objective-C NSDictionary和NSURL的问题

我是Objective-C的新手,我不知道为什么这段代码不起作用:

    NSMutableDictionary *bookmarks = [NSMutableDictionary dictionaryWithCapacity:(NSUInteger) 4];
[bookmarks setObject:@"Stanford University" forKey:[NSURL URLWithString:(NSString *) @"http://www.stanford.edu"]];
[bookmarks setObject:@"Apple" forKey:[NSURL URLWithString:(NSString *) @"http://www.apple.com"]];
[bookmarks setObject:@"Berkeley" forKey:[NSURL URLWithString:(NSString *) @"http://www.berkeley.edu"]];
[bookmarks setObject:@"CS193P" forKey:[NSURL URLWithString:(NSString *) @"http://cs193p.stanford.edu"]];

NSEnumerator *browser = [bookmarks keyEnumerator];
id each;
NSURL *url;
while ((each = [browser nextObject])) {
    url = [browser valueForKey:(NSString *)each];
    NSLog(@"%@", [url absoluteURL]);
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

2009-06-29 11:25:22.844 WhatATool[2102:10b] *** -[NSURL length]: unrecognized selector sent to instance 0x1072c0
2009-06-29 11:25:22.845 WhatATool[2102:10b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', …
Run Code Online (Sandbox Code Playgroud)

debugging nsurl nsdictionary nsstring

2
推荐指数
1
解决办法
1万
查看次数

如何使用进度条和取消按钮实现自定义UIAlertview?

嗨iPhone应用开发人员,

我正在开发一个iphone应用程序.此应用程序允许用户将图像上载到我的服务器.我想在alertView中显示上传进度.我需要一些示例代码来说明如何使用进度条实现自定义UIAlertView.

提前致谢.

iphone uialertview progress-bar

2
推荐指数
1
解决办法
8934
查看次数

设置NSURL,使%@的值等于%@而不是插入%@

我正在使用ASIHTTP并尝试为网站执行GET请求:

NSURL *url = [[NSURL URLWithString:@"/verifyuser.aspx?user=%@" relativeToURL:@"http://domain.com"],userName  retain];       
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setTemporaryFileDownloadPath:@"myfile2.txt"];
[request setDownloadDestinationPath:@"myfile.txt"];

[request startSynchronous];
Run Code Online (Sandbox Code Playgroud)

但是,当我在[request startSynchronous]上放置一个断点并进入调试器时,请求对象的url值等于userName变量.我正在尝试将userName变量插入到字符串中,然后将其用作url,因此我的NSURL声明中的某些内容不正确.

谢谢你的帮助!

iphone nsurl

2
推荐指数
1
解决办法
4033
查看次数

pathForResource不起作用

我有问题

NSString *filePaht = [[NSBundle mainBundle] pathForResource:(NSString *)name ofType:(NSString *)ext];
Run Code Online (Sandbox Code Playgroud)

如果我用的话

NSString *filePaht = [[NSBundle mainBundle] pathForResource:@"soundName" ofType:@"aiff"];
Run Code Online (Sandbox Code Playgroud)

没关系.但是当我用的时候

NSString *fileName = [[file.list objectAtIndex:index] objectForKey:@"soundName"];
NSString *filePaht = [[NSBundle mainBundle] pathForResource:fileName ofType:@"aiff"];
Run Code Online (Sandbox Code Playgroud)

这不行

有什么想法!?

谢谢

cocoa nsbundle

2
推荐指数
1
解决办法
5026
查看次数

objective c NSURL可能不响应+ initFileURLWithPath

我在applicationDidFinishLaunching函数中有两行代码:

NSString *targetFilePath = @"/Users/bob/Documents/About_Stacks.pdf";
NSURL *targetFileURL = [NSURL initFileURLWithPath:targetFilePath];
Run Code Online (Sandbox Code Playgroud)

我在第二行收到警告(标题)......

我不知道我做错了什么.这是一个荒谬的简单应用程序......我已经阅读了有关重新排序方法的其他帖子,但我使用的是NS提供的类,我自己也没有.

任何建议将不胜感激.

谢谢.

cocoa objective-c

2
推荐指数
1
解决办法
1625
查看次数

通过NSUserDefaults的数据持久性

应用程序启动之间NSUserDefaults中的数据是否仍然存在?即使我退出并重新启动应用程序,我仍希望保留一些小数据.

iphone cocoa-touch nsuserdefaults

2
推荐指数
1
解决办法
3942
查看次数

NSURL总是返回零

我有WCF服务,我想从我的网络服务获取数据.但URL始终返回nil.为什么?我想将参数发送到来自文本字段值的WCF.例如;

txtfield.text = @"ATA?EH?R";
Run Code Online (Sandbox Code Playgroud)

怎么了 ?

NSString *request = [NSString stringWithFormat:@"http://www.xxxxxxxx.com/CCWCF.svc/MethodName/%@",txtfield.text];
NSURL *URL = [NSURL URLWithString:[request stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
Run Code Online (Sandbox Code Playgroud)

我尝试了不同的东西,但结果并没有改变.

NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.xxxxxxxx.com/CCWCF.svc/MethodName/%@",txtfield.text]];
Run Code Online (Sandbox Code Playgroud)

要么:

NSURL *URL = [[NSURL alloc] initWithString:[request stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
Run Code Online (Sandbox Code Playgroud)

iphone nsurl ios

2
推荐指数
1
解决办法
2516
查看次数

如何将头信息插入MPMoviePlayerController url?

我需要用http协议实现视频流服务.我知道如何将url设置为MPMoviePlayerController,以及如何将headerField设置为NSMutableURLRequest,但我不知道如何组合它们.我实现如下代码,但不工作,我假设因为二进制数据中没有文件信息.

- (void) openUrl
{
    NSMutableURLRequest *reqURL = [NSMutableURLRequest requestWithURL:
                               [NSURL URLWithString:@"http://111.222.33.44/MOV/2013/4/123123123"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];

    [reqURL setHTTPMethod:@"GET"];
    [reqURL setValue:@"Mozilla/4.0 (compatible;)" forHTTPHeaderField:@"User-Agent"];
    [reqURL setValue:@"AAA-bb" forHTTPHeaderField:@"Auth-Token"];
    [reqURL setValue:@"bytes=0-1024" forHTTPHeaderField:@"Range"];
    [reqURL setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];

    [NSURLConnection connectionWithRequest:reqURL delegate:self];

}


- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{    
    NSLog(@"Received");
    NSError * jsonERR = nil;

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"myMove.ts"];

    [data writeToFile:path atomically:YES];
    NSLog(@"copied");
    NSURL *moveUrl = [NSURL fileURLWithPath:path];

    MPMoviePlayerController *player = [[MPMoviePlayerController alloc]init];
    [player setContentURL:moveUrl];
    player.view.frame = …
Run Code Online (Sandbox Code Playgroud)

xcode mpmovieplayercontroller nsurlconnection nsurlrequest

2
推荐指数
1
解决办法
3307
查看次数