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 Objective-C Basics (Retired) Advanced Objective-C Categories

Swapnil Kapse
Swapnil Kapse
1,162 Points

Issue while trying this tutorial related to categories in xcode6

Hi

I am trying out this tutorial related to categories in xcode6. I am facing below issues

  1. If #import<Cocoa/Cocoa.h> is not present in main.h, I get error for sentence NSLog(@"Initial Capitalized Letters are %@", [letters capitalizedString]); for letters capitalizedString

Error is 'No visible @interface for 'NSArray' declares the selector capitalizedString.' How to resolve this? Has anyone observed this error?

  1. If #import<Cocoa/Cocoa.h> is added in main.h, I get error 'Cocoa/Cocoa.h file not found'. From where can I add this file.

Note : xcode6 new file type selection options are different than shown in tutorials. I am using File > New > IOS > Source > Objective C File > File Type : Category and Class : NSArray

Please help resolving these issues.

3 Answers

Louis DeRienzo
Louis DeRienzo
2,378 Points

I had this same exact problem. Most likely it's because the video is outdated for the new Xcode.

If this helps, go to create a new file, and instead of opening a Cocoa class file, open an empty objective-c file and make sure the file type is category. The rest is the same with the video.

At least that was the problem that I had, followed along with going to Cocoa class when apple moved the category file into the objective-c file.

Judy Tsai
Judy Tsai
6,376 Points

Just checking, do you have both .h files imported?

#import <Cocoa/Cocoa.h>
#import "NSArray+new_mahem.h"
Swapnil Kapse
Swapnil Kapse
1,162 Points

Yes. Its added already.

Judy Tsai
Judy Tsai
6,376 Points

capitalizedStrings is the function associated with NSString. The method declared in mahem file should be capitalizeString, not capitalizedString.

Try changing it to

NSLog(@"Initial Capitalized Letters are %@", [letters capitalizeStrings]);

See if that helps.