小编Rob*_*bin的帖子

4种颜色中的1种返回错误

我定义了4种颜色.

@interface Global : NSObject {

    UIColor *_EnemyColor;
    UIColor *_EnemyColor2;
    UIColor *_TeamColor;
    UIColor *_TeamColor2;

}

@property (nonatomic, retain) UIColor *EnemyColor;
@property (nonatomic, retain) UIColor *EnemyColor2;
@property (nonatomic, retain) UIColor *TeamColor;
@property (nonatomic, retain) UIColor *TeamColor2;

@end
Run Code Online (Sandbox Code Playgroud)

@synthesize EnemyColor = _EnemyColor;
@synthesize EnemyColor2 = _EnemyColor2;
@synthesize TeamColor = _TeamColor;
@synthesize TeamColor2 = _TeamColor2;
Run Code Online (Sandbox Code Playgroud)

然后在init方法中,我尝试为变量设置一些颜色.

- (id)init {
if (self = [super init]) {
    //*******************************************************************
    _TeamColor = [UIColor colorWithRed:0.70196078 green:0.70196078 blue:0.70196078 alpha:1.0];
    //Everything works, if this line is commented out
    _TeamColor2 …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uicolor ios4

1
推荐指数
1
解决办法
757
查看次数

核心数据`deleteObject:`问题!

我在核心数据中有以下实体,如下图所示. 核心数据模型

所有关系的删除规则是级联的.

问题:当我删除级别2中的任何一个实体对象并执行[context save:&error];表Entity1中的所有其他对象时,由于无法再读取Entity1对象而导致数据错误并且应用程序崩溃,从而产生EXC_BAD_ACCESS错误.

我正在使用此代码

for(Entity1 *entity in listOfEntitys)
{
    if(entity.Relation1)
        [context deleteObject:entity.Relation1];

    if(entity.Relation2)
        [context deleteObject:entity.Relation2];

    if(entity.Relation3)
        [context deleteObject:entity.Relation3];
}
[context save:&error];
Run Code Online (Sandbox Code Playgroud)

它不像我从未从核心数据中删除任何对象,但这是问题发生的唯一地方.谁能帮忙.

谢谢.
PS.我在SO上看过其他问题,但没有一个像我一样.

编辑:

我的问题是,当我尝试从级别2删除任何一个对象时,实体1中的所有对象都会出现数据错误.这样的事情.

Printing description of listOfEntitys: 
(
    "<Entity1: 0x4dc3d80> (entity: Entity1; id: 0x4dc2d60 <x-coredata://DF11191D-0BE9-4A63-955D-0A43153290A4/Entity1/p5> ; data: <fault>)",
    "<Entity1: 0x5b06ea0> (entity: Entity1; id: 0x5b077d0 <x-coredata://DF11191D-0BE9-4A63-955D-0A43153290A4/Entity1/p6> ; data: <fault>)",
    "<Entity1: 0x4dc2cf0> (entity: Entity1; id: 0x4dc2df0 <x-coredata://DF11191D-0BE9-4A63-955D-0A43153290A4/Entity1/p7> ; data: <fault>)",
    "<Entity1: 0x4dc2b80> (entity: Entity1; id: 0x4dc3640 <x-coredata://DF11191D-0BE9-4A63-955D-0A43153290A4/Entity1/p8> ; data: <fault>)" 
)
Run Code Online (Sandbox Code Playgroud)

iphone entity-relationship core-data objective-c ios

1
推荐指数
1
解决办法
1992
查看次数

预期';' 在'''令牌错误之前

在我编写代码时,显示的错误是预期';' 在'('标记之前.
这是我指向错误的代码部分.

@class UITableViewCellEditable;

@protocol UITableViewCellEditableDelegate
- (void)editDidFinish:(NSMutableDictionary *)result //    (in this line of code)
{ 
    [userDataSource setValue:[result objectForKey:@"text"]
               forKey:[result objectForKey:@"key"]];
}
@optional
Run Code Online (Sandbox Code Playgroud)

我尝试了一些可能性,但仍然是同样的错误!我怎么处理它?

iphone compiler-errors objective-c ios

1
推荐指数
1
解决办法
190
查看次数

iPhone:超越界限[0 .. 8]'

这真让我抓狂!我一直在崩溃这个错误.以下是我的代码.我试图在我的UITabelView中添加一个额外的单元格以获得"25个以上"的功能.但是我在heightForRowAtIndexPath函数内部崩溃了.我在俯瞰什么?

TIA.

[NSMutableArray objectAtIndex:]:索引4294967295超出边界[0 .. 8]'

0 CoreFoundation
0x01338be9 __exceptionPreprocess + 185 1 libobjc.A.dylib
0x0148d5c2 objc_exception_throw + 47 2 CoreFoundation
0x0132e6e5 - [__ NSArrayM objectAtIndex:] + 261 3
mackdabMobile
0x00004f56 - [AllmackTableViewController tableView:heightForRowAtIndexPath:] +

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
    {
        NSLog(@"IndexRow int: %i", indexPath.row);
        NSLog(@"postsArray count: %i", [postsArray count]);
        if(indexPath.row < [postsArray count]){  **<----Where it crashes**
            Post *myPost = [postsArray objectAtIndex:[indexPath row] - 1];
            NSString *text = myPost.description;

            CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 88.0f);

            CGSize size = …
Run Code Online (Sandbox Code Playgroud)

iphone nsarray ios

0
推荐指数
1
解决办法
1210
查看次数

为什么[self.tableView reloadData]不起作用?

这是cellForRowAtIndexPath:方法的代码.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];

if (cell == nil) { cell = [[[UITableViewCell alloc]
    initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
}

NSUInteger row = [indexPath row]; 
cell.textLabel.text = [array objectAtIndex:row]; 
return cell;    
}
Run Code Online (Sandbox Code Playgroud)

当我[self.tableView reloadData];什么都不用的时候?

iphone objective-c uitableview ios

0
推荐指数
1
解决办法
2万
查看次数