上次我在 Stackowerflow 上发帖时,我搞砸了,因为我认为我知道的比我做的更多。重命名方法以使其更容易,只是让一切变得非常混乱。所以我现在要再试一次。
无论如何,我的申请被 Apple 拒绝了几次,我找不到错误。我一直在运行模拟器以及 AD-HOC 安装,但似乎找不到错误甚至无法复制它。
我没有任何警告,并且一直在使用静态分析器,也找不到任何问题。
我是 Objective C 的新手,我认为我在使用类方法方面做错了,但我不确定。
这是最后一个,类方法“itemStatus”崩溃了。
顺便说一句,我正在使用 ARC。
任何帮助将非常感激。
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x432b2b10
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x3a3c3526 objc_retain + 6
1 Kebunno 0x0008928a +[DynamoDBManager itemStatus] + 418
2 Kebunno 0x000894de +[DynamoDBManager getItem:] + 170
3 Kebunno 0x000908f6 __44-[KebunnoViewController itemPressed]_block_invoke + 362
头等舱
@interface KebunnoViewController ()
// Interface declarations here
@end
@implementation KebunnoViewController
- (IBAction)itemPressed:(id)sender {
NSString *itemID = _itemID.text;
NSString *reference = _reference.text;
BOOL itemCorrect = NO;
if([ItemHelpClass validItem:itemID]){
itemCorrect = YES;
}
if(!itemCorrect){
[[ItemHelpClass showItemNotCorrect:self] show];
return;
}
else if(itemCorrect){
[self startCancelTimer];
[self disableButtons];
dispatch_queue_t backgroundQueue = dispatch_queue_create("background queue", NULL);
dispatch_async(backgroundQueue, ^{
NSString *itemStatus;
itemStatus = [DynamoDBManager getItem:itemID]; //crash
if([itemStatus isEqualToString:NETWORK_ERROR] ||
[itemStatus isEqualToString:AMAZON_ERROR]){
dispatch_async(dispatch_get_main_queue(), ^{
[self enableButtons];
[[ItemHelpClass showSomethingWentWrong:self] show];
});
}
//Code continues
}
@end
另一个名为 DynamoDBMangar.m 的文件
@implementation DynamoDBManager
+(NSString*)getItem:(NSString *)itemID {
NetworkStatus netStatus =
[[Reachability reachabilityForInternetConnection]currentReachabilityStatus];
if(netStatus == NotReachable)
{
return NETWORK_ERROR;
}
NSString *itemStatus = [self itemStatus]; //crash
if([itemStatus isEqualToString: ITEM_BORROWED]){
return ITEM_BORROWED;
}
else if([itemStatus isEqualToString:NETWORK_ERROR])
{
return NETWORK_ERROR;
}
//Code continues
}
+(NSString*) itemStatus{
NetworkStatus netStatus = [[Reachability reachabilityForInternetConnection]currentReachabilityStatus];
if(netStatus == NotReachable)
{
return NETWORK_ERROR;
}
@try
{
DynamoDBGetItemRequest *request = [[DynamoDBGetItemRequest alloc] initWithTableName: TABLE_CONTENT andKey:[[DynamoDBKey alloc] initWithHashKeyElement:
[[DynamoDBAttributeValue alloc] initWithS:[ItemHelpClass getItem]]]];
DynamoDBGetItemResponse *response = [[AmazonClientManager ddb] getItem:request];
if(response){
if(((DynamoDBAttributeValue *)[response.item objectForKey:@"UID_ID"]).s){
return ITEM_BORROWED;
}
else{
return ITEM_NOT_BORROWED;
}
}
}@catch (NSException *exception)
{
[AmazonClientManager wipeCredentialsOnAuthError:exception];
}
return NETWORK_ERROR;
}
@end
编辑:CPU状态
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x200c55c0 r1: 0x432b2b00 r2: 0x00000002 r3: 0x00000020
r4: 0x00000001 r5: 0x200a2d10 r6: 0x1f5c67f0 r7: 0x2fd95a08
r8: 0x200a4260 r9: 0x000fc09c r10: 0x1f5c4c40 r11: 0x200a44e0
ip: 0x3c33c050 sp: 0x2fd95960 lr: 0x0008928f pc: 0x3a3c3526
cpsr: 0x00000030