scanf
目的 c によってコードに情報を含める代わりに、関数を使用するにはどうすればよいですか?
#import <Foundation/Foundation.h>
@interface Person: NSObject
{
NSString *personname;
int personage;
int personweight;
int personheight;
}
-(void) setPersonName:(NSString *)name;
-(void) setPersonAge:(int)age;
-(void) setPersonWeight:(int)weight;
-(void) setPersonHeight:(int)Height;
-(void) SetprintPerson;
@end
@implementation Person
-(void) setPersonName:(NSString *)name
{
personname = name;
}
-(void) setPersonAge:(int)age
{
personage = age;
}
-(void) setPersonWeight:(int)weight
{
personweight = weight;
}
-(void) setPersonHeight:(int)Height
{
personheight = Height;
}
-(void) SetprintPerson
{
NSLog(@"\n person name: %@ \n person age: %i \n person weight: %i KG \n person Height: %i CM",personname,personage,personweight,personheight);
}
@end
int main(int argc, const char * argv[])
{
@autoreleasepool
{
// I wont to use the scanf here .
Person *user = [[Person alloc]init];
[user setPersonName:@"ahmed"];
[user setPersonAge:30];
[user setPersonWeight:176];
[user setPersonHeight:90];
[user SetprintPerson];
}
return 0;
}
私は学習の邪魔をしていて、依頼された仕事に苦労していました。