objc开发问题
xcode吧
全部回复
仅看楼主
level 11
qyfylylljfw 楼主
我新人,写了简单代码,却编译失败,哪位大神能帮我看看哪儿错了?谢谢!
//main.m
#include <Foundation/Foundation.h>
typedef enum
{
Apiano,
Aviolin,
}Different_instruments;
typedef enum
{
Aviolinist,
Apianoist,
}Different_musicions;
typedef struct
{
Different_instruments instrument;
Different_musicions musicion;
}musicion;
@interface Person:NSObject
{
Different_instruments instrument;
Different_musicions musicion;
}
- (void) introMusicion:(Different_musicions) musicion;
- (void) introInstrument:(Different_instruments) instrument;
- (NSString*) Way_of_eat;
- (NSString*) Way_of_sleep;
- (NSString*) introLifestyle;
- (void) intro;
@end
NSString* return_Name(Different_instruments S)
{
switch (S)
{
case Apiano:return @"piano";break;
case Aviolin:return @"violin";break;
}
return @"no cule";
}
@implementation Person
- (void)introMusicion:(Different_musicions)A
{
musicion = A;
}
- (void)introInstrument:(Different_instruments)D
{
instrument = D;
}
- (NSString*) Way_of_eat
{
return@"Eat three meals everyday.";
}
- (NSString*) Way_of_sleep
{
return@"Sleep at 10 o'clock everyday.";
}
- (NSString*) introLifestyle
{
return@"%@ %@",Way_of_eat,Way_of_sleep;
}
- (void) intro
{}
@end
@interface Pianist:Person
@end
@implementation Pianist
- (void) intro
{
NSLog(@"Pianist %@ and he play music by %@",
introLifestyle,
return_Name(S));
}
@end
@interface Violinist:Person
@end
@implementation Violinist
- (void) intro
{
NSLog(@"Violinist %@ and he play music by %@",
introLifestyle,
return_Name(S));
}
@end
void Introduction_musicion(id musicion_types[],int count))
{
int i;
for (i=0;i<count;i++)
{
id musicion_type=musicion_types[i];
[musicion_type intro]
}
}
int main(int argc,const char argv*[])
{
id Musicions[2];
Musicions[0] = [Pinaoist new];
[Musicions[0] introInstrument:Apinao];
Musicions[1] = [Violinist new];
[Musicions[1] introInstrument:Aviolin];
Introduction_musicion(Musicions,2);
return 0;
}
2014年11月09日 04点11分 1
1