小编Coo*_*coa的帖子

将更改推送到远程存储库时,此Git警告消息是什么?

描述有点简洁.我只是在我的本地主分支上添加了一个文件并将其推回到远程仓库.知道为什么会这样吗?

warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning: 
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: …

git version-control

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

为什么NSError需要双重间接?(指向指针的指针)

这个概念似乎给我带来了麻烦.为什么NSError对象需要将其指针传递给正在修改对象的方法?例如,不仅仅是传递对错误的引用做同样的事情吗?

NSError *anError;
[myObjc doStuff:withAnotherObj error:error];
Run Code Online (Sandbox Code Playgroud)

然后在doStuff中:

 - (void)doStuff:(id)withAnotherObjc error:(NSError *)error 
 {
    // something went bad!
    [error doSomethingToTheObject];
 }
Run Code Online (Sandbox Code Playgroud)

为什么上述工作不像大多数其他对象消息传递模式一样有效?为什么必须使用错误:(NSError**)错误?

c cocoa pointers objective-c

46
推荐指数
4
解决办法
1万
查看次数

NSOperation在iPhone上

我一直在寻找一些具体的场景,NSOperation以确定iPhone 何时是应用程序中使用的理想工具.据我所知,这是编写自己的threaded代码的包装器.我还没有看到任何使用它的Apple演示应用程序,我想知道我是否错过了一个很棒的工具而不是使用它NSThread.

这里的理想解决方案是描述用例场景NSOperation以及如何使用它来解决您的问题.

iphone multithreading cocoa-touch objective-c nsoperation

41
推荐指数
5
解决办法
4万
查看次数

这个按位运算如何检查2的幂?

我正在看一些应该是微不足道的代码 - 但我的数学在这里惨遭失败.

这是一个条件,使用以下内容检查数字是否为2的幂:

if((num != 1) && (num & (num - 1))) { /* make num pow of 2 */ }
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何在num和num-1之间使用按位AND来确定数字是2的幂?

c math bit-manipulation

39
推荐指数
4
解决办法
7万
查看次数

将UIDatePicker拟合到UIActionSheet中

我正在尝试使用UIButton获取UIDatePicker以显示在UIActionSheet中.不幸的是,它被裁掉了,整个日期选择器都不可见.我还没有尝试过添加UIButton.任何人都可以建议让整个视图适合吗?我不确定如何添加适当的尺寸,因为UIActionSheet似乎缺少-initWithFrame:类型构造函数.

UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Date Picker" 
                                                  delegate:self
                                         cancelButtonTitle:@"Cancel"
                                    destructiveButtonTitle:nil
                                         otherButtonTitles:nil];

// Add the picker
UIDatePicker *pickerView = [[UIDatePicker alloc] init];
pickerView.datePickerMode = UIDatePickerModeDate;
[menu addSubview:pickerView];
[menu showInView:self.view];

[pickerView release];
[menu release];
Run Code Online (Sandbox Code Playgroud)

我也尝试过类似的东西:

UIActionSheet *menu = [[UIActionSheet alloc] initWithFrame:CGRectMake(200.0, 200.0, 100.0f, 100.0f)];
Run Code Online (Sandbox Code Playgroud)

这些坐标是不现实的,但它们似乎不会影响UIActionSheet的位置/大小.

iphone cocoa-touch objective-c uidatepicker

37
推荐指数
5
解决办法
5万
查看次数

如何在GDB中获取内存地址的符号名称?

例如,我知道0x46767f0属于NSString*,有什么方法可以找出NSString是什么来帮助我找到一些我想要的错误?

memory debugging gdb

37
推荐指数
3
解决办法
4万
查看次数

协议与类别

任何人都可以解释Objective-C中协议类别之间的差异吗?你什么时候用另一个?

objective-c objective-c-category objective-c-protocol

36
推荐指数
4
解决办法
2万
查看次数

在Objective-C中检查对象的大小

我试图找到一个objective-c对象的大小.我正在使用类似的东西:

    NSLog(@"sizeof myObject: %ld", sizeof(*myObject));
Run Code Online (Sandbox Code Playgroud)

这只是给了我指针的大小.

我究竟做错了什么?

c objective-c sizeof

35
推荐指数
6
解决办法
3万
查看次数

`..`在git branch参考中意味着什么?

git log origin/master
git log origin/master..
Run Code Online (Sandbox Code Playgroud)

与上面的确切区别是什么?我试图理解..符号的确切含义.我认为这是一个范围,但在这种情况下,它做了一些不同的事情.

git

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

为什么要将NSObject的协议添加到协议实现中

我一直在看到一些类似于以下内容的代码:

@protocol MyProtocol <NSObject>
// write some methods.
@end
Run Code Online (Sandbox Code Playgroud)

MyProtocol符合NSObject协议有什么特别的原因吗?如果你做的事情如下:

id <MyProtocol> foo; // foo here conforms to NSObject AND MyProtocol?
Run Code Online (Sandbox Code Playgroud)

只是好奇逻辑是什么.

iphone cocoa objective-c

31
推荐指数
3
解决办法
8291
查看次数