我有一个应用程序从SOAP Web服务获取信息,我想在一个显示结果UITableView.
我有一个以前版本的这个应用程序,我正在创建一个新版本,基本上清理东西,摆脱一堆已弃用,不再使用的遗留代码.
在之前的版本中,这很有效.在新版本中,没有那么多.
基本上,当前场景返回3个字符串,我试图用作我的数据的基础UITableView.
我正在努力解决这个问题,因为它太难以追查EXC_BAD_ACCESS错误了!
(顺便说一句,如果有人有办法使调试体验更像Visual Studio,我很乐意听到它!没有任何想法导致错误,并且无法通过我查看,这是非常令人沮丧的崩溃时的局部变量,看看是什么.我已经在异常断点中添加了,但这似乎并不多.)
无论如何,导致出错的行是:
return [[self Libraries] count];
Run Code Online (Sandbox Code Playgroud)
它发生在tableView:numberOfRowsInSection:.
错误消息我得到APPEARS引用应该存储在中的字符串NSMutableArray [self Libraries].
这里发生了什么?
我正在使用ARC,所以不应该正确处理所有内存管理吗?
ANYWHERE我的代码中没有任何手动发布声明!
请帮我解决这个问题!
我正在尝试将自定义委托添加到我的自定义UITableViewCell中.
在这个单元格中,我有一个按钮,需要在ViewController中触发UITableView所在的方法.
我正在做所有常规步骤来添加自定义委托但由于某种原因,当我在运行时打开VC时,应用程序崩溃并给我一个错误的访问错误.
当我评论所有委托代码时,它正常工作,所以我的猜测是我添加委托的方式有问题.当我将我的id属性取消注释时,它似乎崩溃了.
我在VC中实现协议.我确实将委托分配给cellForRowAtIndexPath:中的单元格.所有委托方法都已到位.我一直在其他类中使用类似的构造,但从未在UITableViewCells的子类中使用过.
在我发布一些代码之前,我想知道以前有人遇到过这个bug.是否以及如何解决它或者甚至可以为UITableViewCell子类创建自定义委托.
编辑:
我的customCell.h
#import <UIKit/UIKit.h>
@class MyTableViewCell;
@protocol MyTableCellProtocoll <NSObject>
-(void) didPressButton:(MyTableViewCell *)theCell;
@end
@interface MyTableViewCell : UITableViewCell
{
UIButton *myButton;
id<MyTableCellProtocoll> delegationListener;
}
@property (nonatomic,retain) UIButton *myButton;
@property (nonatomic,assign) id<MyTableCellProtocoll> delegationListener;
- (void) buttonAction;
@end
Run Code Online (Sandbox Code Playgroud)
.M
#import "MyTableViewCell.h"
@implementation MyTableViewCell
@synthesize myButton;
@synthesize delegationListener;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.myButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.myButton.backgroundColor = [UIColor clearColor];
self.myButton.frame = CGRectMake(5, 0, 10, 32); …Run Code Online (Sandbox Code Playgroud) 我在使用启用ARC的NSOperation中保存NSManagedObjectContext时发现了一些问题.没有ARC,一切都很好.在保存期间始终提供EXC_BAD_ACCESS.代码如下所示:
//on the main thread
-(void)someFunc
{
array = ... //fetching an array of entities from a core data
for(SomeEntity * obj in array)
{
NSSomeOperation * op = [[NSSomeOperation alloc] initWithValue:[obj someField]];
//start an operation
}
}
//NSSomeOperation implementation
//...
- (void)main {
//some code
NSError * error = nil;
[mainContext lock];
if (![mainContext save:&error]) { //<--- HERE EXC_BAD_ACCESS
//process error
}
[mainContext unlock];
//some code
}
//...
Run Code Online (Sandbox Code Playgroud)
使用[mainContext setRetainsRegisteredObjects:YES]和objectWithID不能解决此问题.
EXC_BAD_ACCESS(代码= 1)
EXC_BAD_ACCESS(代码= 13)
-[__NSCFType contextDidSave:]: unrecognized selector sent …Run Code Online (Sandbox Code Playgroud) multithreading exc-bad-access core-data objective-c automatic-ref-counting
我有一个基于Apple的PageControl示例的应用程序.第一次加载视图时,滚动视图将加载第0页和第1页.每当启动滚动时,UIKit应该调用scrollViewDidScroll方法吗?
当启动从第0页到第1页的滚动时,应用程序应加载第1页,页面和页面+ 1,(以防止在滚动期间闪烁).
我的应用程序似乎调用了scrollViewDidScroll19次,我的loadScrollViewWithPage:方法每次调用19次,第0页和第1页,在它最终到达第1页和第2页之前,然后它崩溃了.
这些是方法:
- (void)scrollViewDidScroll:(UIScrollView *)sender {
NSLog(@"scrollviewdidscroll");
// We don't want a "feedback loop" between the UIPageControl and the scroll delegate in
// which a scroll event generated from the user hitting the page control triggers updates from
// the delegate method. We use a boolean to disable the delegate logic when the page control is used.
if (pageControlUsed) {
// do nothing - the scroll was initiated from the page control, not …Run Code Online (Sandbox Code Playgroud) 我正在使用OpenGL ES 1.1渲染我正在构建的iPhone游戏.
简而言之,我渲染了3个项目:
基本上,当我在圆圈上调用drawArrays时,我收到一个EXC_BAD_ACCESS错误.我已经测试了基本的iPhone OpenGL模板中的代码,它工作正常,所以我无法真正跟踪它为什么不在这里工作.有人能以正确的方式指出我吗?
这是用于渲染圆的drawCircle代码.
- (void) drawCircles
{
if (!m_circleEffects.empty())
{
int segments = 24;
for (int i = 0; i < m_circleEffects.size(); i++)
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(m_circleEffects[i].position.x, m_circleEffects[i].position.y, 0);
float radius;
if(m_circleEffects[i].isPulseOutward)
radius = cos(m_circleEffects[i].frameCounter * M_PI / 720);
else
radius = sin(m_circleEffects[i].frameCounter * M_PI / 720);
GLfloat circlePoints[segments * 3];
int count = 0;
for (GLfloat i = 0; i < 360.0f; i += (360.0f / segments))
{
circlePoints[count++] = (cos(i * …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
#ifdef DEBUG
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"JSON Parsing Error" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
#endif
Run Code Online (Sandbox Code Playgroud)
此代码在后台线程中执行(负责解析),并且错误仅在每隔一次发生.有什么问题在这里有什么想法吗?
我正在使用DCRoundSwitch一个项目,我基本上需要一个UISwitch我可以编辑其标签内容的地方.
因为我正在使用ARC我重构DCRoundSwitch代码以ARC在xcode中兼容.
在模拟器中编译和运行时,它可以正常工作.
但是,当在设备上运行时,它给了我EXC_BAD_ACCESS近57行DCRoundSwitchKnobLayer.m
GitHub上有一个错误报告,但还没有找到解决方案.
这是给出的代码EXC_BAD_ACCESS:
CGGradientRef CreateGradientRefWithColors(CGColorSpaceRef colorSpace, CGColorRef startColor, CGColorRef endColor)
{
CGFloat colorStops[2] = {0.0, 1.0};
CGColorRef colors[] = {startColor, endColor};
//THIS LINE BREAKS THE PROGRAM
CFArrayRef colorsArray = CFArrayCreate(NULL, (const void**)colors, sizeof(colors) / sizeof(CGColorRef), &kCFTypeArrayCallBacks);
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, colorsArray, colorStops);
CFRelease(colorsArray);
return gradient;
}
Run Code Online (Sandbox Code Playgroud)
任何线索将不胜感激.
编辑:这是xcode的局部变量:

cocoa-touch exc-bad-access objective-c ios5 automatic-ref-counting
当我尝试使NSURLSession实例无效时,我遇到了一个奇怪的问题.代码非常简单:我有一个View Controller,两个按钮(start:和stop :),以及一个url的文本字段.
一个简单的代码摘录:
- (IBAction)start:(id)sender {
NSURLSessionConfiguration *conf = [NSURLSessionConfiguration backgroundSessionConfiguration:@"conf"];
self.session = [NSURLSession sessionWithConfiguration:conf delegate:self delegateQueue:nil];
NSURLSessionDownloadTask *task = [self.session downloadTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url.text]]];
[task resume];
}
- (IBAction)cancel:(id)sender {
[self.session invalidateAndCancel];
}
Run Code Online (Sandbox Code Playgroud)
或者,如果您愿意,整个项目:链接
现在,尝试下载文件(http://download.thinkbroadband.com/1GB.zip).
由于我希望此下载在后台继续,我正在使用后台会话.
会话正确启动,下载在后台继续,但如果我尝试取消它(发送invalidateAndCancel),我的访问权限很差.
启用Zombie的分析给出了这个僵尸对象:_NSCFBackgroundDownloadTask.
因此,如果我保留NSURLSessionDownloadTask(使用强大的属性来存储它),则不会发生错误访问.但是,AFAIK,NSURLSession应该保留它自己的任务,所以我想了解我的代码有什么问题(也许我在文档中遗漏了什么?)或者我应该提交bug报告.
谢谢
我遇到了一个错误,我不确定它是否是Swift语言或bug的限制.这是最基本的前提:
class GenericClass<T> : NSObject {
var inputValue: T
init(value: T) {
self.inputValue = value
super.init()
}
}
class SubClass : GenericClass<String> {
override init(value: String) {
super.init(value: value)
}
}
var test = GenericClass(value: "test") //Succeeds
var test2 = SubClass(value: "test2") //Fails with EXC_BAD_ACCESS
Run Code Online (Sandbox Code Playgroud)
我这里没有编译器警告,但是Subclass拒绝实例化.我在子类化泛型的特定上下文中有一个更复杂的目标,但上面这个基本问题是我把它归结为.
有趣的是,如果我删除GenericClass上的NSObject继承(和泛型的init方法中的super.init()),这个设置没有问题,所以我认为它必须与我的事实有关继承自NSObject.我的完整实现必须继承自NSOperation(我基本上是使用泛型超类生成自定义的NSOperation类),所以从NSObject继承(即NSOperation)对我来说不是可选的.
令人讨厌的是没有编译器错误,我得到的东西和EXC_BAD_ACCESS一样令人讨厌.这让我觉得这可能是有用的,但目前还不行.我知道他们最近才开始支持Swift中泛型类的子类化.我正在运行最新的xCode beta 6.
有任何见解赞赏!
我理解错误的EXC_BAD_ACCESS含义一般,但我对我的情况发生了什么感到困惑.
我有一个具有NSComparator属性的自定义类sortWithThisComparator.如果该属性由用户设置,当我将项插入实例的类属性数组时,items我使用比较器来确定插入位置:
- (void) insertItem:(id<NSCoding, CKArchivingItem>) item {
if (arrayObjectClassString && ![item isKindOfClass:NSClassFromString(arrayObjectClassString)]) {
[NSException raise:@"YOU MADE A MISTAKE" format:@"you tried to insert a %@ but I can only accept %@", [item class], arrayObjectClassString];
} else {
if (!sortWithThisComparator) {
[self.items addObject:item];
} else {
NSInteger newItemIndex = [self.items indexOfObject:item inSortedRange:NSMakeRange(0, [self.items count]) options:NSBinarySearchingFirstEqual usingComparator:sortWithThisComparator];
if (newItemIndex >= [self.items count]) {
[self.items addObject:items];
} else {
[self.items insertObject:item atIndex:newItemIndex];
}
}
} …Run Code Online (Sandbox Code Playgroud) exc-bad-access ×10
objective-c ×6
ios ×2
cocoa-touch ×1
core-data ×1
delegates ×1
generics ×1
ios4 ×1
ios5 ×1
ios7 ×1
iphone ×1
memory ×1
nsarray ×1
nsobject ×1
nsurlsession ×1
opengl-es ×1
render ×1
sorting ×1
swift ×1
uialertview ×1
uiscrollview ×1
uitableview ×1
xcode ×1