iOS5, StoryBoards, ARC: Weird categories issue

2019-08-12 16:32发布

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条回答
Root(大扎)
2楼-- · 2019-08-12 16:54

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.

查看更多
登录 后发表回答