4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

循環参照を回避する

Last updated at Posted at 2012-12-26

参照:http://d.hatena.ne.jp/dice-t/20101215/1292392076

×

classA.h
#import "classB.h"

@interface classA {
  classB objB;
}
classB.h
#import "classA.h"

@interface classB {
  classA objA;
}

error: expected specifier-qualifier-list before 'ClassA' とかのコンパイルエラーになる。

classA.h
@class classB;

@interface classA {
  classB objB;
}
classA.m
#import "classB.h"

@implementation classA 

@end
classB.h
@class classA;

@interface classB {
  classA objA;
}
classB.m
#import "classA.h"

@implementation classB 

@end

C++といっしょだぬ。
まぁ循環参照が必要な時点でちょっと行けてない設計なわけだが。

4
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?