2014-02-15 4 views
0

다음과 같은 클래스가 있습니다.개체 유형에 속성을 찾을 수 없습니다.

#import <Foundation/Foundation.h> 

@interface JAMToDoItem : NSObject 



@property(nonatomic,strong) NSString *itemName; 
@property BOOL * completed; 
@property (readonly) NSDate * CreactionDate; 
//-(void)MarkAsCompleted:(BOOL)IsComplete onDate:(NSDate*)date; 

@end 

JAMToDoItem.m 파일

// 
// JAMToDoItem.m 
// ToDoList 
// 
// Created by juanabreu on 2/15/14. 
// Copyright (c) 2014 juanabreu. All rights reserved. 
// 

#import "JAMToDoItem.h" 


@interface JAMToDoItem() 
//@property NSDate *completionDate; 

@end 



@implementation JAMToDoItem 


@end 

내가 다음과 메신저

// 
// JAMToDoList.m 
// ToDoList 
// 
// Created by juanabreu on 2/15/14. 
// Copyright (c) 2014 juanabreu. All rights reserved. 
// 

#import "JAMToDoList.h" 
#import "JAMToDoItem.h" 



@interface JAMToDoList() 
@property NSMutableArray *toDoItems; 

//@property(nonatomic,strong) NSString *itemName; 
@end 

@implementation JAMToDoList 
//@synthesize itemName; 

-(IBAction)unwindToRootVC:(UIStoryboardSegue *)segue 
{ 



} 



- (id)initWithStyle:(UITableViewStyle)style 
{ 
    self = [super initWithStyle:style]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    //instatiate the array; 
    self.toDoItems = [[NSMutableArray alloc]init]; 
    [self LoadInitialData]; 

    // Uncomment the following line to preserve selection between presentations. 
    // self.clearsSelectionOnViewWillAppear = NO; 

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
    // self.navigationItem.rightBarButtonItem = self.editButtonItem; 
} 


-(void)LoadInitialData{ 

    JAMToDoItem *TheItem = [[JAMToDoItem alloc]init]; 
    TheItem.itemName [email protected]"Buy Milk"; 

} 





- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
#warning Potentially incomplete method implementation. 
    // Return the number of sections. 
    return 0; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
#warning Incomplete method implementation. 
    // Return the number of rows in the section. 
    return 0; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    // Configure the cell... 

    return cell; 
} 

/* 
// Override to support conditional editing of the table view. 
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Return NO if you do not want the specified item to be editable. 
    return YES; 
} 
*/ 

/* 
// Override to support editing the table view. 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 
     // Delete the row from the data source 
     [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    } 
    else if (editingStyle == UITableViewCellEditingStyleInsert) { 
     // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 
    } 
} 
*/ 

/* 
// Override to support rearranging the table view. 
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 
{ 
} 
*/ 

/* 
// Override to support conditional rearranging of the table view. 
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Return NO if you do not want the item to be re-orderable. 
    return YES; 
} 
*/ 

/* 
#pragma mark - Navigation 

// In a story board-based application, you will often want to do a little preparation before navigation 
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    // Get the new view controller using [segue destinationViewController]. 
    // Pass the selected object to the new view controller. 
} 

*/ 

@end 

참고 오류 점점처럼이 클래스의 propertys에 액세스하려고 : LoadInitialData가 시행되고있다을 다른 클래스와 메신저 JAMToDoItem 속성을 instatiate하려고합니다. 저는 기본적으로 APPLE이 작성한 자습서를 따르고 있습니다. Here입니다. 내 todolist 클래스의 맨 위에는 내가 설정하려고하는 propertys가 들어있는 클래스 인 #import "JAMToDoItem.h"이 있고 어디에서 오류가 발생하는지 알 수 있습니다.

그래서 나는

Property 'itemName' not found on object of type 'JAMToDoItem *' 

로 끝날 오류가 나는 무엇을 놓치고?

+0

코드를 추가하십시오. 속성에 액세스하지 않으면 오류가 나타 납니까? – gran33

+0

gran33 전화를 걸고있는 전체 수업을 추가하여 다른 어떤 코드를보고 싶은지 알려주십시오. 속성에 액세스하지 않고 오류가 나타나지 않습니다. – user677275

+3

메소드와 변수 이름을 대문자로하지 마십시오. – nhgrif

답변

1

UPD :

이유가

// 
// JAMToDoItem.h 
// ToDoList 
// 
// Created by juanabreu on 2/15/14. 
// Copyright (c) 2014 juanabreu. All rights reserved. 
// 

#import <UIKit/UIKit.h> 

@interface JAMToDoItem : UIViewController 


@end 

다른 JAMToDoItem.h 파일 당신은 그것은 ToDoList/ToDoList/JAMToDoItem.h에 위치해 있습니다

#import "JAMToDoItem.h" 

에 명령 + 마우스 왼쪽 버튼을 클릭하여 찾을 수 있습니다, 그리고 것입니다 당신이 우리에게 보여준 것이

ToDoList/JAMToDoItem.h 
,
  1. 파일 삭제 ToDoList/ToDoList/JAMToDoItem.hToDoList/JAMToDoItem.h에서 ToDoList/ToDoList/JAMToDoItem.m

  2. 이동 파일과 ToDoList/ToDoList/JAMToDoItem.hToDoList/JAMToDoItem.mToDoList/ToDoList/JAMToDoItem.m

  3. 를 (선택 및 삭제 히트)를 프로젝트에 JAMToDoItem.hJAMToDoItem.m에 대한 참조를 삭제

    프로젝트를 선택하고 프로젝트에 다시 추가하십시오.

+1

코드를 재구성하는 좋은 단계. – Pawan

+0

나는 그런 나귀 같은 기분이야. 고맙습니다. xcode에 있었을 때 파일을 한 디렉토리에서 다른 디렉토리로 드래그 했으므로 배울 수 있도록 복사 응결 레슨을 만들어야합니다. 고맙습니다 ! – user677275

관련 문제