Java:
object.method(param);
Objective-C:
[object method:param];
Java:
public Feature addFeature (String name, String value, boolean isOptional);
Objective-C:
-(Feature*) addFeature :(NSString*)name withValue:(NSString*)value asOptional:(BOOL) optional:
SEL selector = @selector(addFeature:withValue:asOptional:);
Java
Objective-C:
@interface NSString (LetsAugment)
-(BOOL) isGoodActor;
@end
if ([@”Steven Seagal” isGoodActor]) NSLog (@”Yeah!”) else NSLog (@”What's wrong with you?”);
Java:
MyTao tao = null;
int howManyHands = tao.clap();
Objective-C:
MyTao* tao = nil;
int howManyHands = [tao clap];
Java: ()
class Profile {
int getVersion() {
...
}
class Feature {
Profile getProfile(String name) {
...
}
class Phone {
Feature getFeature(String name) {
...
}
class PhoneFactory {
static Phone designAndProduce(String model) {
...
}
}
...
int version = 0;
Phone phone = PhoneFactory.designAndProduce(“iphone5”);
Feature btFeature = phone.getFeature(“bt”);
if (btFeature != null) {
Profile profile = btFeature.getProfile(“a2dp”);
if (profile != null) {
version = profile.getVersion();
}
}
Objective-C:
@interface Profile : NSObject
@property (readonly) int version;
@end
@interface Feature : NSObject
- (Profile*) getProfile:(NSString*)name;
@end
@interface Phone : NSObject
+ (Phone*) designAndProduce:(NSString*)name;
-(Feature*) getFeature:(NSString*)name;
@end
...
Phone* phone = [Phone designAndProduce:@"iphone5"];
Feature* btFeature = [phone getFeature:@"bt"];
Profile* profile = [btFeature getProfile:@"a2dp"];
int version = profile.version;
Source: https://habr.com/ru/post/138441/
All Articles