main.m// microblog//#import <Foundation/Foundation.h> #import "Person.h" #import "BlogMaster.h" # Import "Microblog.h" int main (int argc, const char * argv[]) {person * person = [[Person alloc]init]; [Person ShowName]; NSLog (@ "%@", person); Person * mans = [[person alloc]init]; [Man ShowName]; Microblog * microblog = [[microblog alloc]init]; return 0;}
#import <Foundation/Foundation.h> @interface person:nsobject{ /** used to record a person's name * * * NSString * _name; /** used to record the Age of Man * * int _age; /** used to record the date of birth * * NSString * _birthday; /** used to record gender */ char _sex; /** used to record the location of * * * NSString * _address; /** used to record the status of emotions * * NSString * _emotion; /** used to record blood type * * NSString * _BLOODTYPE;} @property NSString * NAME; @property int age ; @property NSString * birthday; @property char sex; @property NSString * Add Ress, @property NSString * emtion; @property NSString * bloodtype;-(void) showname; @end
#import "Person.h" #import <Foundation/Foundation.h> @implementation person-(void) showname{ NSLog (@ " Printing person's name "); NSLog (@ "%@", _name);} -(NSString *) description{ return [nsstring stringwithformat:@ "name =%@ age =%d Birth date =%@ sex =%c address =%@ emotional status =%@ blood type =%@", _name , _age,_birthday,_sex,_address,_emotion,_bloodtype]; } @end
#import <Foundation/Foundation.h> #import "BlogMaster.h" #import "Person.h" @interface microblog:nsobject{ /** used to store blogger Information *///blogmaster * _blogmaster; /** used to store the registration time * * NSString * _registertime; /** Brief Introduction */ NSString * _introductionaboutblog; /** used to record blog content * * * NSString * _blogcontent; /** used to record the content of comments * * NSString * _commentcontent; /** used to record the number of comments */ int _commentamount; /** is used to record the number of likes */ int _praiseamount; /** used to record the time of Weibo * * * NSString * _publishtime; /** used to record the number of forwards */ int _transpond;} @property NSString * registertime; @property nsstring * introductionaboutblog; @property nsstring * blogcontent; @property NSString * commentcontent; @property nsstring * publishtime; @property int commentamount; @property int praiseamount;@ property int transpond;//-(void) Printblogmastername: (person *) person; @end
#import "Microblog.h" @implementation microblog//-(void) Printblogmastername: (person *) person//{// if ([person Iskindofclass:[blogmaster class])// {// Blogmaster * master = (Blogmaster *) person;// }// [Master showname];//}-(NSString *) description{ return [nsstring stringwithformat:@ "Blog content =%@ comments number =%d likes quantity =%d publish time =%@ Number of forwards =%d ", _blogcontent,_commentamount,_praiseamount,_publishtime,_transpond];} @end
#import "Person.h" @interface blogmaster:person{ }-(void) showname; @end
#import "BlogMaster.h" @implementation blogmaster-(void) showname{ NSLog (@ "Blogger's name");} @end
Design and implementation of the micro-blog developed by iOS