小编Sea*_*ean的帖子

获取目录中的文件计数

如何计算目录中的文件?我在类引用中找不到任何相关内容NSFileManager.

cocoa objective-c nsfilemanager ios

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

- (void)alertViewCancel :( UIAlertView*)不调用alertView

我遇到了UIAlertViewDelegate方法- (void)alertViewCancel:(UIAlertView*)alertView在我用取消按钮取消AlertView时没有被调用的问题.

奇怪的是委托方法- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex工作正常.

有没有人有想法?

在此先感谢
肖恩

- (void)alertViewCancel:(UIAlertView *)alertView
{   
    if(![self aBooleanMethod])
    {
        exit(0);
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    //some code
}   
Run Code Online (Sandbox Code Playgroud)

单击一个按钮时我会调用它:

- (void)ImagePickDone
{
    UIAlertView *alertDone = [[UIAlertView alloc] 
                          initWithTitle:@"Done" 
                          message:@"Are u sure?"
                          delegate:self 
                          cancelButtonTitle:@"Cancel" 
                          otherButtonTitles: @"Yes", nil];
    [alertDone show];   
    [alertDone release];
}
Run Code Online (Sandbox Code Playgroud)

iphone methods delegates uialertview

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

在NSDocumentDirectory中创建子文件夹

我只是想知道是否可以在NSDocumentDirectory中创建一个子文件夹并将数据写入该创建的文件夹,如:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);    
NSString *dirPath =[[paths objectAtIndex:0] stringByAppendingPathComponent:@"TestFolder"];  
NSString *filePath =[dirPath stringByAppendingPathComponent:@"testimage.jpg"];  
[imageData writeToFile:filePath atomically:YES];
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的支持!

directory objective-c nsdocument

5
推荐指数
2
解决办法
5377
查看次数

从uitableview崩溃中删除行

我只是尝试UITableView使用以下代码从a中删除一行:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
     if (editingStyle == UITableViewCellEditingStyleDelete)
     {
         [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
     }
}
Run Code Online (Sandbox Code Playgroud)

问题是我的应用程序崩溃了.(GDB:程序收到信号:"EXC_BAD_INSTRUCTION".)有人知道为什么吗?

iphone crash row uitableview

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

检查if(country == @"(null)"是否有效

我遇到了if语句不起作用的问题.在第一个代码行之后,变量包含值"(null)",因为从他的iphone地址簿中选择联系人的用户没有为此联系人设置国家/地区密钥,所以这么好.

但如果我检查变量,它将不会是真的,但值肯定是"(null)"...有人有想法吗?

 NSString *country = [NSString [the dict objectForKey:(NSString *)kABPersonAddressCountryKey]];

 if(country == @"(null)")
 {
      country = @"";
 }
Run Code Online (Sandbox Code Playgroud)

谢谢提前
肖恩

iphone null if-statement

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