我正准备将第一个应用程序发布到应用程序商店,我一直在阅读"iPhone人机界面指南"和相关文档,以检查我可能缺少的内容.
我想问一下,在提交应用程序以获得批准时,人们最常犯的错误是什么.
我正在考虑要求人们失踪等.
一个问题是是否需要设备旋转,如果需要,是否需要旋转所有四个方向.
我想这是一个非常基本的问题,但我正在做一本来自Nick Kuh的书"Foundation iPhone App Development"的教程,我不完全理解这一行:
int count = [self count];
......真的是以"自我"开始了吗?
这是整个代码:
#import "NSMutableArray+Shuffle.h"
@implementation NSMutableArray (Shuffle)
- (void)shuffle {
int count = [self count];
NSMutableArray *dupeArr = [self mutableCopy];
count = [dupeArr count];
[self removeAllObjects];
for (int i = 0; i < count; i++) {
// Select a random element between i and the end of the array to swap with.
int nElement = count - i;
int n = (arc4random() % nElement);
[self addObject:dupeArr[n]];
[dupeArr removeObjectAtIndex:n];
}
} …Run Code Online (Sandbox Code Playgroud) 有人可以解释这个"if声明"有什么问题吗?我明白了:
"左值作为任务的左操作数".
这不起作用:
if ([[prepDataArray objectAtIndex:iNDEX] boolValue] = YES) {
NSLog(@"HARD");
}
Run Code Online (Sandbox Code Playgroud)
虽然这有效:
diffQ = [[prepDataArray objectAtIndex:iNDEX] boolValue];
if (diffQ = YES) {
NSLog(@"HARD");
}
Run Code Online (Sandbox Code Playgroud)
我确实意识到问题所在,并且'左值'表示我需要在左侧有不同的东西,但我不知道为什么以及如何在'if'语句中执行我想要的内容,如第一个示例中所尝试的那样.
如果有人能给我一个提示,我将不胜感激:-)
我试图划分整数但结果得到0.我只是不明白我做错了什么.我在这个例子中只使用了int,但是用float或double得到了相同的结果测试.
我使用的代码是:
int wrongAnswers = askedQuestions - playerResult;
int percentCorrect = (playerResult / askedQuestions) * 100;
int percentWrong = (wrongAnswers / askedQuestions) * 100;
NSLog(@"askedQuestions: %i", askedQuestions);
NSLog(@"playerResult: %i", playerResult);
NSLog(@"wrongAnswers: %i", wrongAnswers);
NSLog(@"percentCorrect: %i", percentCorrect);
NSLog(@"percentWrong: %i", percentWrong);
NSLog(@"calc: %i", (wrongAnswers + playerResult));
NSLog(@"wrong answers %: %i %%", ((wrongAnswers / askedQuestions) * 100));
Run Code Online (Sandbox Code Playgroud)
我得到的结果是:
2011-01-09 16:45:53.411 XX [8296:207] askQuestions:5
2011-01-09 16:45:53.412 XX [8296:207] playerResult:2
2011-01-09 16:45:53.412 XX [ 8296:207] wrongAnswers:3
2011-01-09 16:45:53.413 XX [8296:207] percentCorrect:0%
2011-01-09 16:45:53.414 XX [8296:207] …
我升级到XCODE 4.2,突然我得到了所有这些警告信号.大多数我能够修复,但以下我不知道如何.我试图阅读它但仍然有问题.
不推荐使用的代码是:
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease];
Run Code Online (Sandbox Code Playgroud)
我知道我需要使用以下内容:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
Run Code Online (Sandbox Code Playgroud)
但是,当我测试时,我遇到了CellFrame等问题.
有人可以给我一个提示,我应该如何用initWithStyle替换已弃用的代码并得到相同的结果?
这是完整的代码:
- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier {
CGRect CellFrame = CGRectMake(0, 0, 300, 60);
CGRect Label1Frame = CGRectMake(10, 10, 290, 25);
CGRect Label2Frame = CGRectMake(30, 33, 270, 25);
CGRect Label3Frame = CGRectMake(30, 56, 270, 25);
UILabel *lblTemp;
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease];
//Initialize Label with tag 1.
lblTemp = [[UILabel alloc] initWithFrame:Label1Frame];
lblTemp.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.3f alpha:1.0f]; …Run Code Online (Sandbox Code Playgroud) 我正在尝试第一次在异步函数中使用元组。测试时我无法捕捉到响应。我一直在谷歌搜索这个问题,但无法解决它。
我想运行一个返回三个字符串的异步函数。我无法收到回复。已尝试引用项目或名称。
这是代码:
var _moonAndSunResult = CleanSunAndMoonJson(_moonJson);
print(_moonAndSunResult);
Run Code Online (Sandbox Code Playgroud)
尝试以不同的方式引用 _moonAndSunResult 。
// async Task<Tuple<string, string, string, string>> CleanSunAndMoonJson(string _json)
async Task<(string, string, string, string)> CleanSunAndMoonJson(string _json)
{
print("sunRise: " + GetCorrectTimeFormat("sunRise", _json));
print("sunSet: " + GetCorrectTimeFormat("sunSet", _json));
print("moonRise: " + GetCorrectTimeFormat("moonRise", _json));
print("moonSet: " + GetCorrectTimeFormat("moonSet", _json));
Utility.sunrise = GetCorrectTimeFormat("sunRise", _json);
Utility.sunset = GetCorrectTimeFormat("sunSet", _json);
Utility.moonrise = GetCorrectTimeFormat("moonRise", _json);
Utility.moonset = GetCorrectTimeFormat("moonSet", _json);
await Task.Yield();
//return (firstValue, secondValue, thirdValue);
//return new Tuple<string, string, string, string>(Utility.sunrise, Utility.sunset, Utility.moonrise, Utility.moonset);
return (Utility.sunrise, …Run Code Online (Sandbox Code Playgroud) objective-c ×6
iphone ×3
app-store ×1
async-await ×1
c# ×1
deprecated ×1
tuples ×1
types ×1
xcode4.2 ×1