Expected specifier-qualifier-list before 'string'

With the latest version of Xcode from Apple, I have the following problem.

Upon launching, and starting a new project, no matter what the project, I get an error.

Let's say I would like to build a "Mac OS X Command Line Tool" of type "Foundation".

Then, to add a new class, I go to File > Add File > Cocoa Class > Objective-C Class (subclass of NSObject).

Next, in the .h file of the new class created, I replace with the following code:

//
//  newclass.h
//  Untitled
//

#import <Cocoa/Cocoa.h>


@interface newclass : NSObject
{
    string userName;
}

@property string userName;

@end

And then the implementation with the following code:

//
//  newclass.m
//  Untitled
//

#import "newclass.h"


@implementation newclass

@synthesize userName;

@end

And then click "Build & Run" the following errors occur:

newclass.h:11: error: expected specifier-qualifier-list before 'string'

newclass.h:14: error: expected specifier-qualifier-list before 'string'

newclass.m:11: error: no declaration of property 'userName' found in the interface

What am i doing wrong? I've looked up similar previous questions and they have all had to do with the fact that there have been missing or incorrect inputs as far as I can tell.

I can't seem to find out how mine would relate considering everything is from a new project.

Answers


I think you're looking for NSString *. string is a C++ class and Objective-C is not C++.


Need Your Help

show existing selection for dynamic checkbox

c# javascript asp.net

I am creating checkboxes dynamically and want to show the existing selection or want to check them dynamically.this is the code to create checkboxes

Async task raises NotImplementedException

c# windows-phone-8.1 async-await .net-4.5

I continue to struggle with Windows Phone programming. :)

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.