0

I have been following Apple's Start Developing iOS Apps Today guide and have run into a problem. I'm not a newbie developer but I am new to iOS development and I can't see why I'm going wrong.

I have a file called STRAddTodoViewController.h which contains the following

#import <UIKit/UIKit.h>
#import "STRTodo.h"

@interface STRAddTodoViewController : UIViewController
@property STRTodo *todoItem;
@end

And in my STRTodosViewController.m I have:

- (IBAction)unwindToList:(UIStoryboardSegue *)segue {
    STRAddTodoViewController *addTodo = [segue sourceViewController];
    STRTodo *item = addTodo.todoItem;
    if (item != nil) {
        [self.todos addObject:item];
        [self.tableView reloadData];
    }
}

And I'm getting an error of:

Property 'todoItem' not found on object of type 'STRAddTodoViewController *'

For some reason, my public variable in STRAddTodoViewController isn't getting picked up in my other controller and I can't for the life of me figure out why. Any clues?

EDIT: Massive apologies everyone, seems like I had two copies of STRAddTodoViewController in my project and it was reading the old one when it was building. Such a simple mistake and I feel like a massive idiot now, but thanks to everyone who helped me out.

Rik
  • 95
  • 2
  • 7

2 Answers2

0

Try to replace #import "STRTodo.h" by @class STRTodo; in your STRAddTodoViewController.h header file and add #import "STRTodo.h" in your STRAddTodoViewController.m implementation file.

Because if you already #import "STRTodo.h" and #import "STRAddTodoViewController.h" in your STRTodoViewController.h header file, compiler founds too much #import "STRTodo.h" and gets confused.

Does it helps ?

iGranDav
  • 2,450
  • 1
  • 21
  • 25
  • No luck unfortunately, I stripped back all the #import's to the bare minimum too and it still has the same error – Rik Dec 15 '13 at 01:51
0

You have: @property STRTodo *todoItem; This means that STRTodo is indeed a class. Your property requires more identifiers. @property (nonatomic, strong) STRTodo *totoItem;

In addition to this, in your -(id) init method, you should also instantiate the property.

- (id) init{
    if (self = [super init]{
        self.todoItem = [[STRTodo alloc]init];
    }
    return self;
}

Hope this helps.

EDIT: Nevermind, it seems you have found your solution.

erdekhayser
  • 6,537
  • 2
  • 37
  • 69