Tag: Objective C

初始化NSURL对象时,“线程1:在断点处停止”错误

我正在关注iTunes U上的斯坦福大学iOS开发课程。 在其中一个演示(我一直在试图遵循)中,有这样的代码从NSURL加载属性列表,并将其作为NSMutableDictionary返回。 -(NSMutableDictionary *) words { NSURL *wordsURL=[NSURL URLWithString:@"http://cs193p.stanford.edu/vocabwords.txt"]; words=[[NSMutableDictionary dictionaryWithContentsOfURL:wordsURL] retain]; return words; } 应用程序被成功构build,但是在运行时它会给出以下错误并被卡住: 我找不出什么问题。 你能帮忙吗?

在iOS上发送HTTP POST请求

我试图发送一个HTTP Post与我正在开发的iOS应用程序,但推送永远不会到达服务器,虽然我得到一个代码200作为响应(从URL连接)。 我从来没有得到从服务器的响应也没有检测到我的post(服务器检测到来自android的post) 我确实使用ARC,但将pd和urlConnection设置为较强。 这是我发送请求的代码 NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",dk.baseURL,@"daantest"]]]; [request setHTTPMethod:@"POST"]; [request setValue:@"text/xml" forHTTPHeaderField:@"Content-type"]; NSString *sendString = @"<data><item>Item 1</item><item>Item 2</item></data>"; [request setValue:[NSString stringWithFormat:@"%d", [sendString length]] forHTTPHeaderField:@"Content-length"]; [request setHTTPBody:[sendString dataUsingEncoding:NSUTF8StringEncoding]]; PushDelegate *pushd = [[PushDelegate alloc] init]; pd = pushd; urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:pd]; [urlConnection start]; 这是我代表的代码 #import "PushDelegate.h" @implementation PushDelegate […]

SpriteKit – 创build一个计时器

我如何创build一个计时器,每隔两秒钟触发一次,将屏幕上的HUD上的分数递增1? 这是我对HUD的代码: @implementation MyScene { int counter; BOOL updateLabel; SKLabelNode *counterLabel; } -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { counter = 0; updateLabel = false; counterLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"]; counterLabel.name = @"myCounterLabel"; counterLabel.text = @"0"; counterLabel.fontSize = 20; counterLabel.fontColor = [SKColor yellowColor]; counterLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter; counterLabel.verticalAlignmentMode = SKLabelVerticalAlignmentModeBottom; counterLabel.position = CGPointMake(50,50); // change x,y […]