- #include <stdio.h>
- #import <Foundation/Foundation.h>
- //未运行成功
- //方法的声明
- @interface Car : NSObject //是这个类具有创建对象的功能
- {
- // 实例变量/成员变量的声明
- @public
- int wheels ;
- int speeds ;
- }
- - (void)run;
- @end
- @implementation Car
- -(void)run
- {
- NSlog(@"这个车的轮子是%d个,车的速度是%dkm/h",wheels,speeds);
- }
- @end
- int main()
- {
- Car *p = [Car new];
- p->wheels = 4 ;
- p->speeds = 20 ;
- [p run];
-
- return 0;
- }
复制代码 以下事终端提示的20十个错误,初学者很头疼- In file included from 方法与成员变量.c:2:
- In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:397:1: error:
- expected identifier or '('
- @class NSString, Protocol;
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:399:19: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT NSString *NSStringFromSelector(SEL aSelector);
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:400:44: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:402:19: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT NSString *NSStringFromClass(Class aClass);
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:403:43: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT Class NSClassFromString(NSString *aClassName);
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:405:19: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) NS_AVAI...
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:405:50: error:
- unknown type name 'Protocol'
- FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) NS_AVAI...
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:406:19: error:
- unknown type name 'Protocol'
- FOUNDATION_EXPORT Protocol *NSProtocolFromString(NSString *namestr) NS_AV...
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:406:50: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT Protocol *NSProtocolFromString(NSString *namestr) NS_AV...
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:410:30: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:410:53: error:
- format argument not an NSString
- FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
- ^ ~
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:98:49: note:
- expanded from macro 'NS_FORMAT_FUNCTION'
- #define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString_...
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:411:31: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_F...
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:411:63: error:
- format argument not an NSString
- ...void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0);
- ^ ~
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:98:49: note:
- expanded from macro 'NS_FORMAT_FUNCTION'
- #define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString_...
- ^
- In file included from 方法与成员变量.c:2:
- In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
- In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
- In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:8:
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:8:1: error:
- expected identifier or '('
- @class NSString;
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:16:52: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT void NSSetZoneName(NSZone *zone, NSString *name);
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:17:19: error:
- unknown type name 'NSString'
- FOUNDATION_EXPORT NSString *NSZoneName(NSZone *zone);
- ^
- In file included from 方法与成员变量.c:2:
- In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
- In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:10:1: error:
- expected identifier or '('
- @class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:11:1: error:
- expected identifier or '('
- @class Protocol;
- ^
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:15:1: error:
- expected identifier or '('
- @protocol NSCopying
- ^
- fatal error: too many errors emitted, stopping now [-ferror-limit=]
- 20 errors generated.
- MacdeiMac:1119晚上 Mac$
复制代码
|