Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Diary App Using Core Data Deleting and Updating Data Updating Data

Anand P
Anand P
893 Points

How to get @class DiaryEntry and @property to work in EntryViewController using Swift instead of Objective-C

Need some help to get through this, I am trying to build this app in swift as I learn through your videos in Obj-C.

The app is stuck at a point where clicking on an entry to edit does nothing. No errors, compile/runtime but I believe something is wrong with how I could not recreate a forward class declaration for THDiaryEntry and the entry property in Swift.

I did follow the interoperability method given in apple docs to create header file and utilize Bridging-Header in order to get the @class/@propert work in swift as a workaround but I am not able to get visibility for both in EntryViewController.

Any help is much appreciated.

3 Answers

Make sure your project recognizes your newly created bridging-header file as THE bridging-header file. Go to your target -> build settings -> in the search field type "bridging header" -> make sure your file is being displayed as the value for key "Objective-C Bridging Header". If not, change it to your file.

Anand P
Anand P
893 Points

Thanks Stephen, I did try that and the auto-complete while using the entities created in the header file never seemed to work. Alternatively, I chose to use a nested struct to create a class type/variable (do let me know if this is an acceptable practice).

However, I am still stuck with the problem where clicking on an entry in the RootViewController does not take me to the "edit" view. Some print statements later, I see that the segue.identifier is coming through as nil. I checked/rechecked/recreated the segue with the identifier "edit" which is being evaluated in the prepareForSegue but no luck yet.

Thoughts?

Could you upload your project so I can take a look?