这是我假设的一个非常简单的问题.有人可以告诉我部署目标的含义.如果我选择IOS 10,这是否意味着只有拥有iOS 10的用户才能下载该应用.选择较低的部署目标是不是很糟糕?另外,继续部署目标,不建议在较低的部署目标上运行.
如何解决KERN_PROTECTION_FAILURE和KERN_INVALID地址?当我运行我的应用程序时,两者似乎都发生在完全相同的位置.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x6d783f44
Crashed Thread: 2
Thread 2 Crashed:
0 libobjc.A.dylib 0x34a80464 objc_msgSend + 16
1 Foundation 0x31171dda __+[__NSOperationInternal _observeValueForKeyPath:ofObject:changeKind:oldValue:newValue:indexes:context:]_block_invoke_7 + 10
2 libSystem.B.dylib 0x30dd9678 _dispatch_call_block_and_release + 12
3 libSystem.B.dylib 0x30dd9b98 _dispatch_worker_thread2 + 120
4 libSystem.B.dylib 0x30d7e24a _pthread_wqthread + 258
5 libSystem.B.dylib 0x30d76970 start_wqthread + 0
Run Code Online (Sandbox Code Playgroud)
和:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000011
Crashed Thread: 7
Thread 7 Crashed:
0 libobjc.A.dylib 0x34a80464 objc_msgSend + 16
1 Foundation 0x31171dfc -[NSOperation completionBlock] …Run Code Online (Sandbox Code Playgroud) 当我从表中删除行时,我的应用程序崩溃了.以下是检测到错误和堆栈跟踪的源代码.感谢名单!
//delete row from database
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"\ncommitEditingStyle");
//delete user from Users table with specified ID
if(editingStyle == UITableViewCellEditingStyleDelete)
{
//Get the object to delete from the array.
[dbManager open: @DB_FILE_NAME];
//get userID from array usersIDList[row] = userID!
NSNumber *usersID = [usersIDList objectAtIndex: [indexPath row]];
[dbManager deleteUserWithID: [usersID intValue] table: @TABLE_USERS fieldName: @"UserID" ];
[dbManager close];
//Delete the object from the table.
[self.tableView deleteRowsAtIndexPaths:
[NSArray arrayWithObject: indexPath]
withRowAnimation: UITableViewRowAnimationFade];
}
}
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation …Run Code Online (Sandbox Code Playgroud) 正如Apple在"Swift编程语言"中所说,似乎我们应该unowned比weak任何可能的更喜欢:
如果捕获的引用永远不会变为nil,则应始终将其捕获为无主引用,而不是弱引用.
从本页的"弱和无主参考"部分
我确实知道这两者之间的区别.但我好奇的是有没有很好的理由,宁愿 unowned比weak?我认为weak更安全,我们可以总是编写[weak obj]和可选的绑定检查,而不考虑存在的可能性obj.
它与某些性能考虑或我错过的东西有关吗?或者是否完全可以使用weak而不是一直使用unowned?
我的想法已经不多了.我收到一个EXC_BAD_ACCESS使用ARC的项目.根据调试器,它在内main().NSZombieEnabled设置为YES但我没有看到任何callstack或Class/Type或任何东西.检查器/配置文件也是如此.在应用程序崩溃后的某个时间,我得到的只是"会话超时".
而且很难在我的代码中找到它.
我正在设置像
NSLog(@"CrashLog: <%@:%@:%d:%s>", NSStringFromClass([self class]),
NSStringFromSelector(_cmd), __LINE__, __FILE__);
Run Code Online (Sandbox Code Playgroud)
关于enty和退出方法的代码,但我还没有找到任何有用的模式.我所能看到的是,所有我所讨论的方法都已经EXC_BAD_ACCESS被抛弃了.
有关如何隔离问题的任何想法?
Tim建议在gdb中使用back trace(bt).结果是:
#0 0x0be87580 in TI::Favonius::BeamSearch::choose_hit_test_node ()
#1 0x0be87b5f in TI::Favonius::BeamSearch::update_for_touch ()
#2 0x0be8ee32 in TI::Favonius::StrokeBuildManager::update_search_for_touch ()
#3 0x0be8f58f in TI::Favonius::StrokeBuildManager::key_down_or_drag_hit_test_for_UI ()
#4 0x0be6ba8b in TIInputManagerZephyr::simulate_touches_for_input_string ()
#5 0x0be7e5d9 in -[TIKeyboardInputManagerZephyr candidates] ()
#6 0x00678345 in -[UIKeyboardImpl generateAutocorrectionReplacements:] ()
#7 0x007dcaec in __71-[UITextInteractionAssistant scheduleReplacementsForRange:withOptions:]_block_invoke_0 ()
#8 0x007f6db2 in -[UITextSelectionView calculateAndShowReplacements:] ()
#9 0x00e255fd in __NSFireDelayedPerform ()
#10 0x01a03976 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#11 …Run Code Online (Sandbox Code Playgroud) 提前感谢您提供有关我所遇到的问题的任何帮助/见解.就在最近,我的iOS应用程序因可怕的EXC_BAD_ACCESS错误而开始失败.我对SO和Google进行了大量研究,并收到了一些很好的建议,但这些帖子都没有帮助我解决我的问题.到目前为止,我知道EXC_BAD_ACCESS可能是两件事之一:
1) A pointer is now pointing to memory that was deallocated.
2) A pointer itself is corrupt.
Run Code Online (Sandbox Code Playgroud)
我阅读并按照这里,这里,这里和这里的说明进行操作.当我执行"构建并运行"时,我可以100%重现exc_bad_access.但是,当我在调试器或工具中启用NSZombie时,我永远无法重现该问题.此外,NSZombie不会在控制台中留下任何有用的信息.
我最接近确定问题的方法是在每一行代码之后放置一个NSLog,以便查看崩溃的位置.我相信它在两个截然不同的地方崩溃 - 这两个点都在返回一个单元格cellForRowAtIndexPath.下面我提供了两种方法,我认为事情正在崩溃,以及我的控制台上的错误输出.任何帮助或指导将不胜感激,谢谢!
违规方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
static NSString *CellIdentifier = @"EventDetailCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.textColor = [UIColor colorWithRed:150 green:143 blue:135 alpha:1.0];
cell.textLabel.highlightedTextColor = [UIColor …Run Code Online (Sandbox Code Playgroud) 突然,我在这一行得到了EXC_BAD_ACCESS:
int retVal = UIApplicationMain(argc, argv, nil, nil);
Run Code Online (Sandbox Code Playgroud)
这是代码:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
Run Code Online (Sandbox Code Playgroud)
我甚至不知道从哪里开始看?
有人可以帮忙吗?
我有一个UIFont类,看起来像这样:
struct FontHelper {
func defaultFont(size: CGFloat) -> UIFont {
return UIFont(name:"Helvetica", size: size)!
}
}
Run Code Online (Sandbox Code Playgroud)
我称之为这样的方法"
let fonts = FontHelper.defaultFont(12)
Run Code Online (Sandbox Code Playgroud)
然而,我的应用程序崩溃与意外发现nil包装可选?
不明白为什么?
Program received signal: “EXC_BAD_ACCESS”.
(gdb) bt
#0 0x30011940 in objc_msgSend ()
#1 0x30235f24 in CFRelease ()
#2 0x308f497c in -[UIImage dealloc] ()
#3 0x30236b78 in -[NSObject release] ()
#4 0x30a002a0 in FlushNamedImage ()
#5 0x30250a26 in CFDictionaryApplyFunction ()
#6 0x30a001a4 in _UISharedImageFlushAll ()
#7 0x30a00738 in +[UIImage(UIImageInternal) _flushCacheOnMemoryWarning:] ()
#8 0x3054dc80 in _nsnote_callback ()
#9 0x3024ea58 in _CFXNotificationPostNotification ()
#10 0x3054b85a in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#11 0x3054dbc0 in -[NSNotificationCenter postNotificationName:object:] ()
#12 0x30a00710 in -[UIApplication _performMemoryWarning] ()
#13 0x30a006a8 in …Run Code Online (Sandbox Code Playgroud) 当我尝试创建方法的实例时,我收到EXC_BAD_ACCESS错误.
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(40,38,240,203)];
DetailImageViewDataSource *detail=[[DetailImageViewDataSource alloc] init];//**error line**
@implementation DetailImageViewDataSource
@synthesize webdata,xmlParser,soapResults,newImage;
-(void) startParsing
{
recordResults=FALSE;
NSString *soapMessage=[NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<GetImage xmlns=\"http://tempuri.org/\">\n"
"<imageID>f89df9ad-5a5d-4354-895f-356d8ce4ccfb</imageID>\n"
"</GetImage>\n"
"</soap:Body>\n"
"</soap:Envelope>\n"];
//http://192.168.2.7/ImageWebService/Service1.asmx
//http://192.168.2.7/ThesisWebServicesNew1/Service.asmx
NSLog(soapMessage);
NSURL *url=[NSURL URLWithString:@"http://192.168.2.7/ThesisWebServicesNew1/Service.asmx"];
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:url];
NSString *msgLength=[NSString stringWithFormat:@"%d",[soapMessage length]];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"http://tempuri.org/GetImage" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webdata=[[NSMutableData data] retain];
NSLog(@"got connected");
}
else
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试完成我的C编程课的作业Xcode。这很简单。它读取一个文本文件,其中包含学生 ID 及其考试成绩的列表。然后它根据这些数据计算总分,并将它们写入另一个文本文件。但是,我不断收到此Bad Access错误消息,内容为:
Thread 1: EXC_BAD_ACCESS(code=1, address=0x7fff00000de4)
Run Code Online (Sandbox Code Playgroud)
我不知道这是什么意思。我该怎么办?
ios ×4
iphone ×4
objective-c ×4
xcode ×4
crash ×2
debugging ×2
swift ×2
c ×1
callstack ×1
class ×1
cocoa-touch ×1
delete-row ×1
ios10 ×1
ipad ×1
stack-trace ×1
uifont ×1
uitableview ×1