小编Jos*_*nto的帖子

每次运行后,Xcode 6会继续在iOS8模拟器中重命名我的应用程序目录.

我正在运行Xcode 6 Beta 5,但自第一次测试以来,这种情况一直在发生.模拟器中的应用程序目录在每次运行后都会被重命名.我花了一段时间来弄明白这一点.我正在使用它来获取doc的dir参考.

NSString *folder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                        NSUserDomainMask,
                                                        YES) lastObject];

NSLog(@"Documents Dir: %@",folder);
Run Code Online (Sandbox Code Playgroud)

现在例如在第一次运行时它将是:

/ Users/Joey/Library/Developer/CoreSimulator/Devices/5B9930EE-A9B4-4B36-BABB-AA864ACAF2DE/data/Containers/Data/Application/4B10C2E4-A5C3-4C64-93B1-4069FCCB9C46/Documents

现在第二次运行:

/ Users/Joey/Library/Developer/CoreSimulator/Devices/5B9930EE-A9B4-4B36-BABB-AA864ACAF2DE/data/Containers/Data/Application/7E9EB62D-115A-4092-AD23-CB6BA3E5E10F/Documents

第三轮:

/ Users/Joey/Library/Developer/CoreSimulator/Devices/5B9930EE-A9B4-4B36-BABB-AA864ACAF2DE/data/Containers/Data/Application/EC8F41E8-52ED-4B10-9808-B3ACC46FC6AA/Documents

这对我的应用程序造成了严重破坏,因为它存储了应用程序中某些文件的路径引用.这不是我的NSLog语句返回不正确的结果,我验证了这是在Finder中发生的事情.它每次都在改变这个名字.有没有人见过这种情况?这是一个我误解的"特征"吗?

xcode objective-c ios xcode6 ios8

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

ffmpeg不会在我的项目中构建,在示例应用程序中工作正常

我已经尝试了几个小时,但我无法弄清楚这一点.我在我的项目中使用KXMOVIE.我按照指示下载并编译了ffmpeg二进制文件.示例应用程序实际上工作正常,但我不能让它在我自己的项目中构建.所有.a文件都在那里,它与示例应用程序中的文件完全相同.当我尝试为模拟器构建时,我收到此错误.

Undefined symbols for architecture i386:
  "_iconv", referenced from:
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
  "_iconv_close", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
  "_iconv_open", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我甚至不知道从哪里开始.

xcode ffmpeg clang ios

6
推荐指数
1
解决办法
1519
查看次数

UITableView使用UIPIckerView滚动到特定部分?

我有一个UITableView具有固定数量的部分,但每个部分中的行数可能会有所不同,具体取决于服务器结果.

我想实现一个拣选轮来"跳"到每个部分.这是我在UITableViewController中的UIPickerView委托方法:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{

return 1;

}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return 5;
}

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return [self.pickerArray objectAtIndex:row];
}
Run Code Online (Sandbox Code Playgroud)

在ViewDidLoad中初始化的"pickerArray":

self.pickerArray = [[NSArray alloc]initWithObjects:@"Watching", @"Completed", @"On Hold", @"Dropped", @"Planned", nil];
Run Code Online (Sandbox Code Playgroud)

这是我的didSelectRow方法:

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
[self.tableView scrollToRowAtIndexPath:[self.pickerArray objectAtIndex:row] atScrollPosition:UITableViewScrollPositionNone  animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

我注意到没有"scrollTo*section*AtIndexPath"方法,这会有所帮助.Apple的文档说这是关于"indexpath"参数:

indexPath
An index path that identifies a row in the table view by its row index and its section index.
Run Code Online (Sandbox Code Playgroud)

调用方法(在选择器中拾取内容)会引发此错误:

*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [__ NSCFConstantString section]:无法识别的选择器发送到实例0x4bdb8'

知道我应该做什么吗?

objective-c uitableview uipickerview

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

嵌套语句而不是创建新的一次性对象?

这里有新问题.

我为什么要这样做:

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"(lineNum = %d)", i];
    [request setPredicate:pred];
Run Code Online (Sandbox Code Playgroud)

当我能做到这一点?

    [request setPredicate:[NSPredicate predicateWithFormat:@"(lineNum = %d)", i]];
Run Code Online (Sandbox Code Playgroud)

我找到的每个教科书代码示例都使用第一种方法,但据我所知,第二种方法基本上会做同样的事情,只是看起来更整洁."pred"只被调用一次所以为什么要把它作为一个对象?

cocoa cocoa-touch objective-c

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

可以将对象从IF语句范围中传出吗?

这是我的代码.编译器抱怨范围内未使用的变量,并使用未声明的变量超出范围.我明白那个.该对象需要在IF语句之前声明,因此可以从双方访问它.但这是扭曲.

我不能预先声明对象,因为对象将来自哪个类取决于IF语句的结果.这是我坚持使用的代码摘录.

if (!([self.defaults valueForKey:@"unofficialAPIOn"])) {

        MALInterfaceController *interface = [[MALInterfaceController alloc]init];

    }
    else{

        MALControllerUnofficial *interface = [[MALControllerUnofficial alloc]init];

    }

    [interface verifyAuth:self.usernameField.text forPassword:self.passwordField.text];
Run Code Online (Sandbox Code Playgroud)

MALInterfaceController和MALControllerUnofficial基本上都是具有相同方法等的类,但是针对两个不同的API进行了定制.如何向上传递*interface对象?

if-statement objective-c

0
推荐指数
1
解决办法
119
查看次数