我正在努力学习C,现在我正在学习字符.我已经读过一些字符可以签名和未签名的地方.这部分我得到但是当我使用unsigned char(我认为它可以保持0-255的值)
printf("%c", 400);
Run Code Online (Sandbox Code Playgroud)
甚至
printf("%c\n", (unsigned char)400);
Run Code Online (Sandbox Code Playgroud)
它打印出一个 É
为什么是这样?
我已经在目标c中尝试类型安全了一段时间。我想我得到了一些,但我想知道以下可能性是否可能。
NSMutableArray <NSNumber *> *x = [NSMutableArray new];
[x addObject:@14];
[x addObject:@"s"]; // <--- Gives warning, good!
for (NSUInteger i = 0; i < x.count; i++) {
NSString *s = [x objectAtIndex:i]; // <-- Gives warning, good!
}
NSString *d = x[0]; // <-- Gives warning, good!
//but
for (NSString *s in x) // <-- expected warning but didn't get it
NSLog(@"%@", [s stringByAppendingString:@"s"]; // <-- no warning just run time error
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,当使用了不正确的对象时,for循环可以发出警告。我想在其中使用for,因为它速度快并且隐藏了实现的细节。
我正在尝试在导航控制器中为右边的条形项设置图像,但iOS 6会一直显示黑色光晕.我已尝试过堆栈溢出的许多解决方案但无法使其工作.我目前的代码是这样的:
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"gear"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(someMethod)];
[rightItem setImageInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
[[self navigationItem] setRightBarButtonItem:rightItem];
Run Code Online (Sandbox Code Playgroud)
在iOS7中看起来像这是我想要的:
这就是它在iOS6中的外观 
我试图与数字值相互比较,但我得到警告"不同符号的整数比较:'NSInteger'(又名'inti)和'NSUInteger'(又名'unsigned int').
这是合乎逻辑的,因为我这样做;).但是我该如何修复此警告.这是引发警告的代码:
if (page >= self.controllers.count || page < 0)
return;
Run Code Online (Sandbox Code Playgroud)
页面可以是-1,因此它是NSInteger但count返回NSUInteger.
我正在尝试通过代码构建一个View.在我的初学者我有这个:
- (id) init{
self = [super init];
if(self){
[self setFrame:CGRectMake(0, 0, 0, 50)];
[self addSubview:[self dateNumberView]];
NSDictionary *views = NSDictionaryOfVariableBindings(self.dateNumberView);
[self.dateNumberView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-[dateNumberView]-|" options:0 metrics:nil views:views]];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: dateNumberView is not a key in the views dictionary. |-[dateNumberView]-|
Run Code Online (Sandbox Code Playgroud)
怎么了?
我是CSS的初学者,所以这可能是一个愚蠢的问题,但我仍然无法弄明白:).我试图用百分比将3个区块放在一起.到目前为止我所拥有的是:
#notification {
display: inline-block;
height: 100px;
width: 100%;
}
#date_pane{
display: inherit;
height: inherit;
width:15%;
}
#text_pane{
display: inherit;
height: inherit;
width: 75%;
}
#arrow_pane{
display: inherit;
height: inherit;
width:10%;
}
Run Code Online (Sandbox Code Playgroud)
最后一个方格站在下一行.我不知道为什么?有人知道这会发生什么吗?
我的HTML是:
<div id="notification">
<div id="date_pane"></div>
<div id="text_pane"></div>
<div id="arrow_pane"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是一个小提琴
我想在UIButton内部IB 上添加一个视图.唯一的问题是它不允许我只在顶部放入按钮内?
这是不可能通过IB或我做错了吗?
我开始学习C,我想创建一个字符串.我正在使用的示例是这样做的:
char *c = malloc(2 * sizeof(char)); // 2
*c = 'A';
*c++ = 'B';
printf('%s', c); //doesn't print anything?
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,如何打印字符串AB?
我收到一个字符串:"1 + 2 + 3232 + 4"我想答案:3239.
我如何在Objective-C中执行此操作?
我正在学习C,这可能是有史以来最愚蠢的问题,但它在这里!
我的代码:
char tmp = *x++;
char *g = &tmp;
Run Code Online (Sandbox Code Playgroud)
我可以在一个班轮中执行这行代码吗?有类似的东西:
char *g = &(*x++);
Run Code Online (Sandbox Code Playgroud)
更多信息:
char *x = "1234";
//Turn each 'number' to a int
while(*x != '\0'){
char tmp = *x++;
char *x = &tmp;
int t = atoi(x);
}
Run Code Online (Sandbox Code Playgroud)