iOS5, StoryBoards, ARC: Weird categories issue

跟風遠走 提交于 2019-12-24 10:36:34

问题


I've created a file with sql methods and now this file is really large. I'd like to split it for best practice and implementation simplicity. So, categories.

I've created in xCode new objective-c categories file -> DBAccess+Generals.h (.m).

.h:

#import "DBAccess.h"

@interface DBAccess (Generals)

-(void)newMeth;

@end

.m

#import "DBAccess+Generals.h"
#import "DBAccess.h"

@implementation DBAccess (Generals)

-(void)newMeth
{
  NSLog(@"New Meth");
}

@end

In DBAccess.h

#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "DBAccess+Generals.h"



@interface DBAccess : NSObject
{
   NSString *databaseName;
}

@property(nonatomic,strong)NSString *databaseName;

DBAccess.m

#import "DBAccess.h"
#import "DBAccess+Generals.h"

@implementation DBAccess
@synthesize databaseName;
sqlite3* database=nil;

-(id)init
{
  if ((self=[super init])) 
  {
    //[self initializeDataBase];
    databaseName=@"world_coins.db";
    //firstVerDB=@"ac_ch_ver.1.0.db";

  }
  return self;
}

//Tones of methods

@end

Looks like the code is OK. Getting error "interface implementation not found for DBAccess". I've googled and stackoverflowed around, but the issues described, are not my case.

any help? Thank you in advance.


回答1:


The problem is the cyclic import

  • #import "DBAccess+Generals.h" in DBAccess.h
  • #import "DBAccess.h" in DBAccess+Generals.h

If you remove the first one, the code compiles.



来源:https://stackoverflow.com/questions/12145981/ios5-storyboards-arc-weird-categories-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!