// HelloWorld.m
// HelloWorld
// Copyright (c) 2016 MyappConverter. All rights reserved.
#import "HelloWorld.h"
@implementation HelloWorld
-(void) sayHello {
//You can add your own code block here:
NSString* msg = @"";
NSMutableArray* array = [NSMutableArray array];
[array addObject:@"Try"];
[array addObject:@"CBC"];
for (int i = 0; i < array.count; ++i)
{
NSLog(@"%@", [array objectAtIndex:i]);
}
}
//You can add your own function:
-(float)circleArea:(float)radius{
return radius * radius * 3.14;
}
@end
@interface CBCInterface:NSObject
@property (nonatomic) NSString *name;
@property (nonatomic) int age;
@property (nonatomic) NSArray *hobbies;
-(void) sayMyName;
-(void) displayHobbies;
-(void) dummyMethod;
@end
@implementation CBCInterface
-(void) dummyMethod {
// please insert your code here or add your own methods/functions
}
-(void)sayMyName {
NSLog(@"My name is %@.", _name);
}
-(void)displayHobbies {
_hobbies = [NSArray arrayWithObjects:@"Sports",@"Reading",@"travelling", nil];
for (NSString *item in _hobbies) {
NSLog(@"%@", item);
}
}
@end
@interface NSString(MyCategory)
NSUInteger getLength(NSString *arg);
@end
@implementation NSString (MyCategory )
// category methods
NSUInteger getLength(NSString *arg) {
NSUInteger length =[arg length];
NSLog(@"String length is %lu",(unsigned long)length);
return length ;
}
@end
@interface CBCInterface:NSObject
@property (nonatomic) NSString *name;
@property (nonatomic) int age;
@property (nonatomic) NSArray *hobbies;
-(void) sayMyName;
-(void) displayHobbies;
-(void) dummyMethod;
@end
@implementation CBCInterface
-(void) dummyMethod {
// please insert your code here or add your own methods/functions
}
-(void)sayMyName {
NSLog(@"My name is %@.", _name);
}
-(void)displayHobbies {
for (NSString *item in _hobbies) {
NSLog(@"%@", item);
}
}
@end
@interface NSString (MyCategory)
-(int) getLength:(NSString *)arg;
@end
@implementation NSString (MyCategory)
// category methods
-(int) getLength:(NSString *)arg {
int length =[arg length];
NSLog(@"String length is %@",length);
return length ;
}
@end
