다음과 같은 클래스가 있습니다.개체 유형에 속성을 찾을 수 없습니다.
#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 *'
로 끝날 오류가 나는 무엇을 놓치고?
코드를 추가하십시오. 속성에 액세스하지 않으면 오류가 나타 납니까? – gran33
gran33 전화를 걸고있는 전체 수업을 추가하여 다른 어떤 코드를보고 싶은지 알려주십시오. 속성에 액세스하지 않고 오류가 나타나지 않습니다. – user677275
메소드와 변수 이름을 대문자로하지 마십시오. – nhgrif