정방향 클래스 개체에서 속성을 찾을 수 없습니다.
나는 적응하고있어 이 튜토리얼을 내 애플 리케이션에, 나는 내 트랙에서 저를 중지하고 마지막 오류로 내려 삶은있어. 프로그램이 다른 파일에서 속성을 찾을 수 없지만 해당 속성이 명확하게 정의되어 있습니다. 문제의 코드는 다음과 같습니다.
실제 오류 라인 :
for (DTContact *dtc in _dtContact.contact) {
파일의 .h 및 문제의 항목 :
#import <UIKit/UIKit.h>
@class XMLTestViewController;
@class DTCXMLResponse;
@interface XMLTestController : UIViewController{
UIWindow *window;
XMLTestViewController *viewController;
DTCXMLResponse *_dtContact;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet XMLTestViewController *viewController;
@property (nonatomic, retain) DTCXMLResponse *dtContact;
@property (nonatomic, retain) IBOutlet UIButton *mybutton;
-(IBAction)buttonClicked;
@end
_dtContact.contact에 문제가 있습니다. DTCXMLResponse 파일에서 연락처를 찾을 수 없습니다. 다음은 .h 파일과 .m 섹션입니다.
.h
#import <Foundation/Foundation.h>
@interface DTContactXMLResponse : NSObject {
NSMutableArray *_contact;
}
@property (nonatomic, retain) NSMutableArray *contact;
@end
.미디엄
#import "DTCXMLResponse.h"
@implementation DTContactXMLResponse
@synthesize contact = _contact;
- (id)init {
if ((self = [super init])) {
self.contact = [[NSMutableArray alloc] init];
}
return self;
}
@end
그래서 거기에 있습니다. 보시다시피, DTCXMLResponse.h에 'contact'가 등록되어 있고 .m.
이 오류는 일반적으로 Xcode가 기호를 인식 할 수 없음을 나타냅니다. 이것이 DTContact라고 가정 할 수 있습니다.
.h 파일에 다음을 삽입하십시오.
#import DTContact.h
Its not relevant to ur case but I was getting the same error. I googled for a solution but the problem was in my code. I was using different class object as I was copy pasting similar snippet of code in my project. So here is the problem that I had for the same error :
For my classA , I had some code snippet like :
ManagedObjectOfClassA * managedObjectOfClassA = [NSEntityDescription insertNewObjectForEntityForName:@"ManagedObjectOfClassA" inManagedObjectContext:managedObjectContext];
managedObjectOfClassA.somePropertyA = sameValue; //somePropertyA is an attribute of ManagedObjectOfClassA
And similar code for class B :
ManagedObjectOfClassA *managedObjectOfClassB = [NSEntityDescription insertNewObjectForEntityForName:@"ManagedObjectOfClassB" inManagedObjectContext:managedObjectContext];
managedObjectOfClassB.somePropertyB = someValue;////somePropertyB is an attribute of ManagedObjectOfClassB
If u look closely, the mistake was in assigning the right entities to the corresponding objects in class B.
So the problem is in code of class B. And the correct code would be :
ManagedObjectOfClassB *managedObjectOfClassB = [NSEntityDescription insertNewObjectForEntityForName:@"ManagedObjectOfClassB" inManagedObjectContext:managedObjectContext];
managedObjectOfClassB.somePropertyB.someValue;
I hope that helps someone.
참고URL : https://stackoverflow.com/questions/8577457/property-cannot-be-found-in-forward-class-object
'Programing' 카테고리의 다른 글
JQ : 여러 조건 선택 (0) | 2020.10.21 |
---|---|
Firefox 4 : 필수 양식 입력에서 빨간색 테두리를 제거하는 방법이 있습니까? (0) | 2020.10.21 |
포트 3000에서 수신 대기하는 프로세스를 종료하는 쉘 스크립트? (0) | 2020.10.21 |
Spark 데이터 프레임이 비어 있는지 확인하는 방법 (0) | 2020.10.21 |
힙 메모리 (malloc / new)를 사용하면 비 결정적 프로그램이 생성됩니까? (0) | 2020.10.21 |