我有以下代码行来激活断点
[mapView addAnnotations:grabinstance.itemArray];
Run Code Online (Sandbox Code Playgroud)
随机崩溃.grabinstance.itemArray总是完全填充,并且当时永远不会改变,因为只有在阵列满时才会调用这段代码.这个特定的时间被确认为阵列中的323个项目.
NSZombieEnabled也找不到任何东西.
回溯位于下方,第1154行是上面的一行.
#0 0x0126a372 in _insert ()
#1 0x0126a312 in _splitNode ()
#2 0x0126a3b7 in _insert ()
#3 0x011db253 in -[MKAnnotationContainerView addAnnotation:] ()
#4 0x011dfc2e in -[MKAnnotationContainerView addAnnotations:] ()
#5 0x011b0b30 in -[MKMapView addAnnotations:] ()
#6 0x00009257 in -[BigViewController plotItems] (self=0x614de90, _cmd=0x16464f) at /Users/zzzz/Documents/iPhone Projects/BigProject/Classes/BigViewController.m:1154
#7 0x005336c1 in _nsnote_callback ()
#8 0x01c18f99 in __CFXNotificationPost_old ()
#9 0x01b9833a in _CFXNotificationPostNotification ()
#10 0x00529266 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#11 0x00024071 in -[ItemGrabber parserDidEndDocument:] (self=0x617b540, _cmd=0x689aa3, parser=0xf6b4ab0) at /Users/zzzz/Documents/iPhone …Run Code Online (Sandbox Code Playgroud) 我几天来一直在调试臭名昭着的EXC_BAD_ACCESS错误.NSZombieEnabled = YES没有提供任何东西.每次收到错误时,调用堆栈都不同,每隔5或6次运行一次.
我在Lou Franco的网站上看到了启用guard malloc(现在是Xcode 4的方案编辑器)的提示:了解EXC_BAD_ACCESS.一旦我这样做,我的程序就停止了导致这个难以捉摸的错误的确切行.
根据其描述,guard malloc为每个malloc创建单独的页面,并在释放内存时删除整个页面,从而在访问释放的内存时使程序崩溃.对于一般的开发,为什么我不能一直保持对malloc的保护?它似乎很容易捕获某些类型的内存错误.如果我没有专门测试内存管理或性能,那么使用它有一些缺点吗?
我对NSNotification对象有一种奇怪的行为.
我的应用程序有一个导航控制器,第一个视图是一个表视图,第二个视图只是一个显示所选单元格数据的视图控制器.
所以在这个数据视图控制器中,当我按下按钮时,我发送通知.该通知最初也有效.
但是当我回到表视图,并再次推栈中的数据视图控制器,并通知触摸按钮,整个应用程序没有错误日志崩溃.
Xcode只突出显示这一行:
[[NSNotificationCenter defaultCenter]
postNotificationName:@"toggleNoteView" object:nil];
Run Code Online (Sandbox Code Playgroud)
我发送通知的功能:
- (IBAction) toggleNoteView: (id) sender
{
[[NSNotificationCenter defaultCenter]
postNotificationName:@"toggleNoteView" object:nil];
}
Run Code Online (Sandbox Code Playgroud)
这是接收者:
- (id)init {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(toggleNoteView:)
name:@"toggleNoteView" object:nil];
...
}
- (void) toggleNoteView:(NSNotification *)notif {
takingNotes = !takingNotes;
}
Run Code Online (Sandbox Code Playgroud)
编辑:现在我确实得到了一些错误日志.
2011-06-27 23:05:05.957 L3T[3228:707] -[UINavigationItemView toggleNoteView:]: unrecognized selector sent to instance 0x4b235f0
2011-06-27 23:05:06.075 L3T[3228:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationItemView toggleNoteView:]: unrecognized selector sent to instance 0x4b235f0'
*** Call stack at first throw: …Run Code Online (Sandbox Code Playgroud) 当您按下主页按钮时,SpriteKit应该清理并暂停所有计时器.
但是,我们发现如果您在显示活动SKView时单击主页按钮,则应用程序崩溃.即使该视图已被用户暂停,也会发生这种情况.
奇怪的是,如果你双击主页按钮并转到多任务视图,一切正常.
跟进注意:模拟器在两种情况下都能完美运行,不会发生崩溃
有没有人用SpriteKit看到这个问题?
你找到了原因/解决方案吗?
我正在创建一个类,给定一个object目标,一个selector要监视,并且displayTitle将以这种格式输出一个字符串:@"displayTitle: object.selector".然后,它通过KVO寄存器本身,以便任何时候value的object.selector变化,它可以通知一个视图控制器更新视图.我使用它作为一种抽象和可重用的方式向用户显示对象的各种属性的描述.
当我尝试获取值时object.selector,我无法做到,[object performSelector:selector]因为当您使用带动态选择器的performSelector时,LLVM会出错.所以,我完全按照这个答案提出的建议:我用了objc_msgSend(object, selector).
- (instancetype)initWithSelector:(SEL)selector onObject:(NSObject*)object displayTitle:(NSString*)displayTitle {
self = [super init];
if (self) {
id value;
if ([object respondsToSelector:selector) {
// Used objc_msgSend instead of performSelector to suppress a LLVM warning which was caused by using a dynamic selector.
value = objc_msgSend(object, selector);
} else {
return nil;
}
[self setItemDescription:[NSString stringWithFormat:@"%@: %@", displayTitle, value]]; …Run Code Online (Sandbox Code Playgroud) 我收到了 EXC_BAD_ACCESS。我知道这通常意味着什么:尝试访问不存在(不再存在)的对象是最可能的原因。
那么,我在哪里可以找到呢?
我在网上看了很多帖子,他们都说:
在方案中“启用 NSZombie”。
现在当我运行调试器时,我应该看什么?我看不出有什么区别...
注意:这不是我的代码中的特定错误,而是通常如何在启用 NSZombie 的情况下使用调试器
学习编写swift代码,查看多维数组,想要遍历数组,撤销存储在第二列中的数学函数,然后将其第一列值添加到4个单独的数组(尚未创建),以便最后我将有4个数组,包含第一列的数字.
但是在线
Function = array3D[index]
Run Code Online (Sandbox Code Playgroud)
我收到错误:快速执行被中断的原因是exc_bad_access
有人可以帮忙吗?代码如下
var array3D: [[String]] = [["1", "+"], ["3", "-"], ["5", "x"], ["7", "/"]]
var arrayAdd = [""]
var arrayMinus = [""]
var arrayMultiple = [""]
var arrayDivide = [""]
var count = array3D.count
var countIsZero = false
if count != 0 {
countIsZero = true
}
if countIsZero {
for index in 0...count {
var Function = ""
Function = array3D[count][1]
println(Function)
switch Function {
case "+": arrayAdd.append(array3D[count][0])
case "-": arrayMinus.append(array3D[count][0])
case "x": arrayMultiple.append(array3D[count][0]) …Run Code Online (Sandbox Code Playgroud) 我在Xcode 7中获得了一个带有viewWillTransitionToSize的EXC_BAD_ACCESS.这里发布的解决方案是EXC_BAD_ACCESS,其中包含viewWillTransitionToSize和Xcode 6.3一起工作,直到我升级到XCode 7.
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator)
{
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
if let safeCoordinator = coordinator as UIViewControllerTransitionCoordinator?
{
// Error: EXC_BAD_ACCESS here
print("coordinator != nil")
safeCoordinator.animateAlongsideTransition({ context in
self.tableView.frame = CGRectMake(0, 0, size.width, size.height)
}, completion: nil)
} else {
print("coordinator == nil")
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助都会得到满足.
我有简单的代码将opus帧解码为音频样本.它适用于Android,但它在Unity3D iOS项目中崩溃,并且在常规iOS项目中不会崩溃.
EXC_BAD_ACCESS (code=1, address=0x2f)
Run Code Online (Sandbox Code Playgroud)
两个项目共享相同的opus静态库和头文件.
#include "opus.h"
int test1(){
unsigned char opus_chunk[] = {0x68, 0x97, 0x50, 0x0d,
0xba, 0xa4, 0x80, 0x0d, 0x31, 0x21, 0x9c, 0xcf, 0x74, 0x98, 0xda, 0xc6,
0xd5, 0x27, 0xcb, 0xd9, 0x51, 0xd7, 0xce, 0x90, 0xc5, 0x58, 0x94, 0x53,
0xb0, 0xe9, 0xb4, 0xe4, 0xf4, 0x42, 0x4d, 0xc7, 0xa4, 0x61, 0xfa, 0xfe};
int len = sizeof(opus_chunk);
short samples[5760];
int err1;
OpusDecoder *decoder;
decoder = opus_decoder_create(48000, 1, &err1);
int n = opus_decode(decoder, opus_chunk, len, samples, 5760, 0);
opus_decoder_destroy(decoder);
} …Run Code Online (Sandbox Code Playgroud) 在编写单元测试和嘲笑时,NSTimer我看到了
Exception: EXC_BAD_ACCESS (code=1, address=0x8)
Run Code Online (Sandbox Code Playgroud)
里面
swift_isUniquelyReferenced_nonNull_native
Run Code Online (Sandbox Code Playgroud)
此处访问数组invalidateInvocations(内部func invalidate())时出现这种情况。
class TimerMock: Timer {
/// Timer callback type
typealias TimerCallback = ((Timer) -> Void)
/// The latest used timer mock accessible to control
static var currentTimer: TimerMock!
/// The block to be invoked on a firing
private var block: TimerCallback!
/// Invalidation invocations (will contain the fireInvocation indices)
var invalidateInvocations: [Int] = []
/// Fire invocation count
var fireInvocations: Int = 0
/// Main …Run Code Online (Sandbox Code Playgroud) exc-bad-access ×10
ios ×6
iphone ×2
swift ×2
xcode ×2
annotations ×1
arrays ×1
cocoa-touch ×1
debugging ×1
guard ×1
ios7 ×1
ipad ×1
malloc ×1
mkmapview ×1
objective-c ×1
opus ×1
selector ×1
sprite-kit ×1
swift2 ×1
xcode7 ×1