Tag: 目标C

在iPhone应用程序中调用exit(0)

在我的应用程序的某个时候,我已经做了这个exit(0) ,这使我的应用程序崩溃。 但是我还没有想到当执行这个方法时会调用什么方法。 我把信息放在: (void)applicationWillTerminate:(UIApplication *)application (void)applicationDidEnterBackground:(UIApplication *)application 但是这似乎没有被调用! 任何关于exit(0)完成时调用什么方法的想法?

无法通过iPhone SDK中的获取访问令牌

我正在创build一个Facebook应用程序。 我已经使用FBSDKLoginManager类实现了login。 当我第一次loginFacebook的时候,成功块返回包含访问令牌对象(FBSDKAccessToken对象)的FBSDKLoginManagerLoginResult对象,这个对象被用来共享包含的内容。但是当我尝试获取这个对象的时候(在重新启动应用程序之后)访问令牌使用函数[FBSDKAccessToken currentAccessToken] return nil。 那么如何再次获得访问令牌(FBSDKAccessToken对象)没有loginFacebook的第二次。

我怎样才能从完成块检索返回值?

是否有可能在主线程上运行完成块? 例如,我有一个方法返回一个值: – (int)test { /* here one method is called with completion block with return type void */ [obj somemethodwithcompeltionblock: { /* here I am getting my Int which I want to return */ } ]; } 但是由于完成块在后台线程上运行,我无法看到如何从完成块中返回整数值作为此方法的结果。 我怎样才能做到这一点?

快速创build和播放声音

所以我想要做的就是快速创build和播放声音,当我按下button时,我知道如何在Objective-C中做到这一点,但有谁知道如何在Swift中? Objective-C就是这样: NSURL *soundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"mysoundname" ofType:@"wav"]]; AudioServicesCreateSystemSoundID((__bridge CFURLRef)soundURL, &mySound); 然后玩它,我会做的: AudioServicesPlaySystemSound(Explosion); 有谁知道我能做到这一点?

目标C iPhone开发中的“委托”是什么?

目标C iPhone开发中的“委托”是什么?

使用Swift的C API

我试图跟踪networking状态。 我经历了FXReachability的代码。 具体如下的方法。 – (void)setHost:(NSString *)host { if (host != _host) { if (_reachability) { SCNetworkReachabilityUnscheduleFromRunLoop(_reachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); CFRelease(_reachability); } _host = [host copy]; _status = FXReachabilityStatusUnknown; _reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [_host UTF8String]); SCNetworkReachabilityContext context = { 0, ( __bridge void *)self, NULL, NULL, NULL }; SCNetworkReachabilitySetCallback(_reachability, ONEReachabilityCallback, &context); SCNetworkReachabilityScheduleWithRunLoop(_reachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); } } 它所做的是不断检查到指定主机的连接。 我试图将此方法转换为Swift,并遇到一些问题。 […]

同时录制和播放audio

任何一个帮助我录制和播放audio同时在iphone中。

'Receiver(<ViewController>)没有标识符“addSegue”

我有一个导航控制器之间有一个segue链接,称为“addSegue”。 当我点击tableView单元格,虽然应用程序崩溃,我得到下面的错误: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<MSAddFriendsViewController: 0x98cc340>) has no segue with identifier 'addSegue' 我不认为我的代码有任何问题。 这里是我有showSegueWithIdentifier行的showSegueWithIdentifier : – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSMutableSet *selectedUsers = [NSMutableSet set]; [self.tableView deselectRowAtIndexPath:indexPath animated:NO]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; cell.accessoryType = UITableViewCellAccessoryCheckmark; PFRelation *friendsRelation = [self.currentUser relationforKey:@"friendsRelation"]; PFUser *user = [self.allUsers objectAtIndex:indexPath.row]; [friendsRelation […]

iOS背景audio没有播放

我有一个使用CoreBluetooth背景模式的应用程序。 当某个事件发生时,我需要发出警报声。 在前台一切工作正常,所有的蓝牙function在后台工作正常。 我也有它工作的地方在后台安排UILocalNotification的声音报警,但是我不喜欢缺乏这些音量控制,所以想用AVAudioPlayer播放报警声音。 我已将背景模式audio添加到我的.plist文件,但无法正确播放声音。 我正在使用一个单独的类来报警,并像这样初始化声音: NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:soundName ofType:@"caf"]]; player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; player.numberOfLoops = -1; [player setVolume:1.0]; 我开始这样的声音: -(void)startAlert { playing = YES; [player play]; if (vibrate) [self vibratePattern]; } 并将其用于振动: -(void)vibratePattern { if (vibrate && playing) { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); [self performSelector:@selector(vibratePattern) withObject:nil afterDelay:0.75]; } } 振动在后台工作正常,但没有声音。 如果我使用Systemsound播放这样的声音,它播放良好(但没有音量控制): […]

iPhone使用AFNetworking上传多部分文件

在我的iOS应用程序中,我想使用NSMutableURLRequest为多部分文件使用java API上传文件。 这里是显示参数的forms。 <form action="API_URL" encType='multipart/form-data' method=post> <input type=file name="files"> <input type=submit value="Upload Attempt Files"> 编辑form2 <form action='URL' method="post" encType='multipart/form-data'> <input name="key1" value='123'> <input name="key2" value='asdf'> <input name="key3" value='qwerty'> <input name="key4" value='aaa'> <input name="key5" value='aaa'> <input name="key6" value='false'> <input type="file" name="files"> <input type=submit value="Create Forum Posts"> </form> 我怎样才能做到这一点。 这里的这个问题展示了如何在iOS中使用AFNetworking (目标c)上传多部分文件。 但我没有得到如何把参数按照我使用的forms。 请帮助和build议