小编Ari*_*ior的帖子

iPhone模拟器无法播放?

当我在Xcode上按Run并且其他任务已经运行时,会出现以下消息:

正在使用的模拟器.模拟器无法启动,因为它已在使用中.

我和一些朋友核对过,当他们按下运行时,Xcode会自动停止运行任务并运行你想要的应用程序.我该如何配置?

提前致谢,

iphone ios ios-simulator

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

为原型单元格更改了dequeueReusableCellWithIdentifier行为?

在iOS5中,在故事板上使用ARC和原型单元格用于tableView,我可以替换下面的代码:

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView 
  dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] 
      initWithStyle:UITableViewCellStyleDefault 
      reuseIdentifier:CellIdentifier];
}

// Configure the cell...
return cell;
Run Code Online (Sandbox Code Playgroud)

有了这个简单的代码??:

UITableViewCell *cell = [tableView 
  dequeueReusableCellWithIdentifier:@"Cell"];
return cell;
Run Code Online (Sandbox Code Playgroud)

我在这个链接上看到了这个:

http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

提前致谢!

Arildo

iphone cells storyboard tableview ios5

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

ARC和Storyboard的兼容性

考虑到设备和iOS,ARC和Storyboard的兼容性如何?

ARC和Storyboard能在iPhone 3G,3GS,4和4S上运行吗?

ARC和Storyboard能在iOS 4和5上运行吗?

iphone ios automatic-ref-counting

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

使用ARC返回自动释放的对象

假设我在A类中编写了以下代码:

-(NSArray *) returnListNames {

    NSArray *returnList = [NSArray arrayWithArray:myListNames];

    return (returnList);
}
Run Code Online (Sandbox Code Playgroud)

在类BI中,以这种方式在某个范围内获取该列表:

{
    /* Without ARC I would  retain the array returned from ClassA 
       to guarantee its reference like this:
       [[myClassA returnListNames] retain]; */

    NSArray *myNames = [myClassA returnListNames];  

}
Run Code Online (Sandbox Code Playgroud)

考虑到returnList使用自动释放方法分配,我如何保证我不会丢失使用ARC(我不能使用retain)的引用?我必须[[NSArray alloc] init]myNames阵列上使用吗?或者我必须使用allocon returnList而不是autorelease方法?或者我可以依靠ARC吗?还是有其他解决方案吗?

cocoa-touch memory-management objective-c ios5 automatic-ref-counting

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

在@implementation中声明变量

我在一本书中看到了一个显示此代码的示例:

@implementation ViewController
{
    NSString *name;
}
Run Code Online (Sandbox Code Playgroud)

为什么不宣布这个@interface?在声明变量@implementation而不是@interface?中有什么区别?为什么NSString在范围内声明这个?

scope class objective-c variable-declaration

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

哈希表:赎金记录 - Swift 中的黑客排名超时

我的代码没问题,但在一些测试用例上保持时间,有什么改进的技巧吗?我的猜测是 indexOf 函数花费的时间太长。

func checkMagazine(magazine: [String], note: [String]) -> Void {
var mutableMag = magazine
if note.count > mutableMag.count {
    print("No")
    return
}
for word in note {
    if let index = mutableMag.index(of: word) {
        mutableMag.remove(at: index)
    } else {
        print("No")
        return
    }
}
print("Yes") }
Run Code Online (Sandbox Code Playgroud)

请在此链接中找到挑战:https : //www.hackerrank.com/challenges/ctci-ransom-note/problem

arrays dictionary hashmap swift swift3

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