SlideShare a Scribd company logo
1 of 107
"initialize             aMyObject        "
aMyObject initialize.

"    30       setSize          aSquare        "
aSquare setSize : 30.

"                                 +               4   "
total := 3 + 4.

min: other
 ^self < other ifTrue: [self] ifFalse: [other].
//
[receiver msg];

//                        msg:with:
val = [receiver msg: arg1 with: arg2];
//
[receiver msg];

//                        msg:with:
val = [receiver msg: arg1 with: arg2];
#import <Foundation/Foundation.h>

//
@interface MyClass : NSObject {
   int val;
}
- (id)init;
+ (void)classMethod:(id)arg; //
- (id)method:(NSObject*)arg1 with:(int)arg2;
- (id)method:(NSObject*)arg1 param:(int)arg2;
@end

//
@implementation MyClass
+ (void)classMethod:(id)arg {
   // some operation
}
- (id)method:(NSObject*)arg1 with:(int)args2 {
   return obj;
}
- (id)method:(NSObject*)arg1 param:(int)args2 {
   return obj;
}
@end
#import <Foundation/Foundation.h>

//
@interface MyClass : NSObject {
   int val;
}
- (id)init;
+ (void)classMethod:(id)arg; //
- (id)method:(NSObject*)arg1 with:(int)arg2;
- (id)method:(NSObject*)arg1 param:(int)arg2;
@end

//
@implementation MyClass
+ (void)classMethod:(id)arg {
   // some operation
}
- (id)method:(NSObject*)arg1 with:(int)args2 {
   return obj;
}
- (id)method:(NSObject*)arg1 param:(int)args2 {
   return obj;
}
@end
//
[MyClass classMethod:arg];

id obj = [[MyClass alloc]init];
// MyClass* obj = [[MyClass alloc]init];

// method:with:
[obj method :arg with:10];
//            init
- (id)init {
   self = [super init]; //
     if(self != nil) {
         val = 1;
         obj = [[SomeClass alloc] init];
     }
     return self;
}
AlarmFake* f = [[AlarmFake alloc]init];
if( [f conformsToProtocol:@protocol(Alarm)] )
{
 //
}
@interface ObjcClass : NSObject{
@private

 int x_;
@protected //

 int y_;
@public

 int z_;
@package //

 int w_;
}
@end
ObjcClass* oc = [[ObjcClass alloc]init];


 int z = oc->z_; // public

 int x = oc->x_; //
ObjcClass* oc = [[ObjcClass alloc]init];


 int z = oc->z_; // public

 int x = oc->x_; //
@interface ObjcClass : NSObject
- (void)print;
@end

@implementation ObjcClass
- (void)print {

 NSLog(@"ObjcClass print:");
}
- (void)private_print {

 NSLog(@"ObjcClass private_print:");
}
@end

void test() {
   ObjcClass* oc = [[ObjcClass alloc]init];

 [oc print]; // ObjcClass print:

 [oc private_print]; // ObjcClass private_print:
@interface ObjcClass : NSObject
- (void)print;
@end

@implementation ObjcClass
- (void)print {

 NSLog(@"ObjcClass print:");
}
- (void)private_print {

 NSLog(@"ObjcClass private_print:");
}
@end

void test() {
   ObjcClass* oc = [[ObjcClass alloc]init];

 [oc print]; // ObjcClass print:

 [oc private_print]; // ObjcClass private_print:
#include <boost/shared_ptr.hpp>

class CppClass{
public:

 CppClass(){}

 void print() const {

 
    std::cout << "CppClass::print" << std::endl;

 }
};

@interface ObjcClass : NSObject
- (void)print;
@end
@implementation ObjcClass
- (void)print {

 NSLog(@"ObjcClass print");
}
@end

void boost_test(){

 boost::shared_ptr<CppClass> p(new CppClass);

 ObjcClass* oc = [[ObjcClass alloc]init];

 [oc print]; // ObjcClass print

 p->print(); // CppClass::print
}
MyObject* obj = [[MyObject alloc] init];
[obj method :arg with:10];
[nil method :arg with:10]; //
MyObject* obj = [[MyObject alloc] init]; //
[obj retain]; //
NSLog(@"count=%d", [obj retainCount] ); // count=2
[obj release] ; //
[obj release] ; //


//
MyObject* obj = [[[MyObject alloc] init] autorelease];
[obj retain]; //
- (BOOL)respondsToSelector:(SEL)aSelector;



MySubClass* obj = [[MySubClass alloc] init];

if( [obj respondsToSelector:@selector(init)] )
{
    NSLog(@"YES");
}
- (BOOL)respondsToSelector:(SEL)aSelector;



MySubClass* obj = [[MySubClass alloc] init];

if( [obj respondsToSelector:@selector(init)] )
{
    NSLog(@"YES");
}
@interface NSObject <NSObject> {
  Class
 isa;
}

- (id)init;
+ (id)alloc;
- (void)dealloc;
- (id)copy;
+ (Class)superclass;
+ (Class)class;
- (IMP)methodForSelector:(SEL)aSelector;
+ (NSString *)description;
+ (BOOL)isSubclassOfClass:(Class)aClass

@end
- (BOOL)isEqual:(id)object;
- (NSUInteger)hash;

- (Class)superclass;
- (Class)class;
- (id)self;

-   (BOOL)isKindOfClass:(Class)aClass;
-   (BOOL)isMemberOfClass:(Class)aClass;
-   (BOOL)conformsToProtocol:(Protocol *)aProtocol;
-   (BOOL)respondsToSelector:(SEL)aSelector;

-   (id)retain;
-   (oneway void)release;
-   (id)autorelease;
-   (NSUInteger)retainCount;
Class meta = [MySubClass class]; // MySubClass
Class metameta = [meta class];

if( [meta isKindOfClass:[NSObject class]] )
{
    NSLog(@"YES");
}
NSBundle* mainBundle = [NSBundle mainBundle];
NSBundle* moduleBundle = [mainBundle bundleWithPath : @"path"];
NSString* loadbleClassName =


Class c = [moduleBundle classNamed : loadbleClassName ];
id = [[c alloc] init] autorelease];
@interface MySubClass : MyObject {
  int x_;
}
@property int x_;
@end

@implementation MySubClass
-(int)x_{ return x_;}      // getter
-(void)setX_:(int)x { x_ = x;} // setter
@end



  MySubClass* obj = [[MySubClass alloc] init];
  int xx= p.x_;
  p.x_ = 200;
@interface MySubClass : MyObject {
  int x_;
}
@property int x_;
@end

@implementation MySubClass
-(int)x_{ return x_;}      // getter
-(void)setX_:(int)x { x_ = x;} // setter
@end



  MySubClass* obj = [[MySubClass alloc] init];
  int xx= p.x_;
  p.x_ = 200;
@interface MySubClass : MyObject {
  int y_;
}
@property int y_;
@end

@implementation MySubClass
@synthesize y_;
@end



  int yy= p.y_;
  p.y_ = 200;
@interface MySubClass : MyObject {
  int y_;
}
@property int y_;
@end

@implementation MySubClass
@synthesize y_;
@end



  int yy= p.y_;
  p.y_ = 200;
@protocol AlarmReq
-(void)nowTime;
@end

//               “<>”
@interface MyClockReq : NSObject<AlarmReq>
-(void)nowTime;
@end

@implementation MyClockReq
-(void)nowTime{}
@end
@protocol AlarmReq
-(void)nowTime;
@end

//               “<>”
@interface MyClockReq : NSObject<AlarmReq>
-(void)nowTime;
@end

@implementation MyClockReq
-(void)nowTime{}
@end
AlarmFake* f = [[AlarmFake alloc]init];

 id<Alarm> f2 = f;




 if( [f2 conformsToProtocol:@protocol(Alarm)] )
 {
      //
 }
AlarmFake* f = [[AlarmFake alloc]init];

 id<Alarm> f2 = f;




 if( [f2 conformsToProtocol:@protocol(Alarm)] )
 {
      //
 }
@protocol Alarm
  -(void)nowTime;
@optional
  -(void)snooze;
@end

@interface MyClock : NSObject<Alarm>
-(void)nowTime;
//-(void)snooze;
@end
@protocol Alarm
  -(void)nowTime;
@optional
  -(void)snooze;
@end

//-(void)snooze
@interface MyClock : NSObject<Alarm>
-(void)nowTime;
@end

@implementation MyClock
-(void)nowTime { NSLog(@"nowTime"); }
@end

MyClock* a = [[MyClock alloc]init];
[a nowTime];
[a snooze]; //
@protocol Alarm
  -(void)nowTime;
@optional
  -(void)snooze;
@end

//-(void)snooze
@interface MyClock : NSObject<Alarm>
-(void)nowTime;
@end

@implementation MyClock
-(void)nowTime { NSLog(@"nowTime"); }
@end

MyClock* a = [[MyClock alloc]init];
[a nowTime];
[a snooze]; //
@interface MyObject : NSObject {
   int val;
}
- (void)bar;
@end

@implementation MyObject

@end

@interface MyObject(EventHandler)
- (void)buttonClicked;
@end

@implementation MyObject(EventHandler)
- (void)buttonClicked{
   NSLog(@"calll buttonClicked");
}

@end

void category_test(){
  MyObject* obj = [[MyObject alloc]init];
  [obj buttonClicked]; // call buttonClicked
}
@interface NSString(matuura)
- (void)whatsName;
@end

@implementation NSString(matuura)
- (void)whatsName{
   NSLog(@"akihiko matuura");
}
@end

void category_test(){
  NSString* s = [[NSString alloc]init];
  [s whatsName]; // akihiko matuura
}
@try{

    if(                   ){

         //

   
          errorcode = 1000;

   
          [NSException raise : @"Fatal Error occured"
                       format : @"%d", errorcode];

   

   
          //

 
     @throw [[MyException alloc]init];

 }
}
@catch( NSException* ex )
{

  NSLog(@"name=%@, reason=%@",[ex name], [ex reason]);

 [ex raise]; //

   @throw; //
}
@catch( ... )
{

 NSLog(@"unknown exception");
}
@finaly{

}
@try{

    if(                   ){

         //

   
          errorcode = 1000;

   
          [NSException raise : @"Fatal Error occured"
                       format : @"%d", errorcode];

   

   
          //

 
     @throw [[MyException alloc]init];

 }
}
@catch( NSException* ex )
{

  NSLog(@"name=%@, reason=%@",[ex name], [ex reason]);

 [ex raise]; //

   @throw; //
}
@catch( ... )
{

 NSLog(@"unknown exception");
}
@finaly{

}
void blocks_caller( void (^f)(void) )
 {
 
 f();
 }


void blocks_test()
{

 blocks_caller( ^(){ NSLog(@"test1");} );

 blocks_caller( ^(){ NSLog(@"test2");} );
}
Func<int, Func<int, int>> f = x => y => x + y;
Func<int, int> fc = f(1);
int x = fc(3); // 1 + 3




function< function<int(int)> (int) > f =

 
   [] (int x){ return [x](int y){ return x+y;}; };
auto fc = f(1);
int x = fc(3); // 1 + 3
void blocks_test()
{

 typedef int (^add_function)(int);

 add_function (^f)(int) =

 
   
   
   
   ^(int x){

 
   
   
   
   
 return Block_copy(^(int y){ return x+y;});

 
   
   
   
   };



 add_function fc = f(1);

 NSLog(@"blocks_test() fc=%d", fc(3));

 Block_release(fc);
}
for (NSString *element in array) {   }
連邦の白いヤツ 「Objective-C」

More Related Content

What's hot

响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架jeffz
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak PROIDEA
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
 
Djangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicDjangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicNew Relic
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
What’s new in C# 6
What’s new in C# 6What’s new in C# 6
What’s new in C# 6Fiyaz Hasan
 
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationIvan Dolgushin
 
Programmation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptLoïc Knuchel
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в JavaDEVTYPE
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptecker
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
Обзор фреймворка Twisted
Обзор фреймворка TwistedОбзор фреймворка Twisted
Обзор фреймворка TwistedMaxim Kulsha
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserHoward Lewis Ship
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)jeffz
 
Zabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet MensZabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet MensNETWAYS
 
The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.9 book - Part 90 of 210The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.9 book - Part 90 of 210Mahmoud Samir Fayed
 

What's hot (20)

响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
 
Djangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicDjangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New Relic
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
What’s new in C# 6
What’s new in C# 6What’s new in C# 6
What’s new in C# 6
 
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
 
Day 1
Day 1Day 1
Day 1
 
Programmation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScript
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScript
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
 
Обзор фреймворка Twisted
Обзор фреймворка TwistedОбзор фреймворка Twisted
Обзор фреймворка Twisted
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The Browser
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
 
Zabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet MensZabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet Mens
 
The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.9 book - Part 90 of 210The Ring programming language version 1.9 book - Part 90 of 210
The Ring programming language version 1.9 book - Part 90 of 210
 
Jason parsing
Jason parsingJason parsing
Jason parsing
 

Viewers also liked

Viewers also liked (8)

Objc lambda
Objc lambdaObjc lambda
Objc lambda
 
Chakkason.pptx
Chakkason.pptxChakkason.pptx
Chakkason.pptx
 
Essence of the iterator pattern
Essence of the iterator patternEssence of the iterator pattern
Essence of the iterator pattern
 
SPL fukuokaphp_1
SPL fukuokaphp_1SPL fukuokaphp_1
SPL fukuokaphp_1
 
Matuura cpp
Matuura cppMatuura cpp
Matuura cpp
 
型! 型!
型! 型!型! 型!
型! 型!
 
The Essence of the Iterator Pattern
The Essence of the Iterator PatternThe Essence of the Iterator Pattern
The Essence of the Iterator Pattern
 
Iterator Pattern
Iterator PatternIterator Pattern
Iterator Pattern
 

Similar to 連邦の白いヤツ 「Objective-C」

Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone DevelopmentGiordano Scalzo
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perltypester
 
Productaccess m
Productaccess mProductaccess m
Productaccess mAdil Usman
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascriptkvangork
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScriptkvangork
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)AvitoTech
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxwhitneyleman54422
 
Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Tsuyoshi Yamamoto
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascriptReece Carlson
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.jsWebsecurify
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascriptMiao Siyu
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCAWhymca
 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleIan Barber
 
Cross platform Objective-C Strategy
Cross platform Objective-C StrategyCross platform Objective-C Strategy
Cross platform Objective-C StrategyGraham Lee
 
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legione-Legion
 
Less ismorewithcoffeescript webdirectionsfeb2012
Less ismorewithcoffeescript webdirectionsfeb2012Less ismorewithcoffeescript webdirectionsfeb2012
Less ismorewithcoffeescript webdirectionsfeb2012Jo Cranford
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with PythonHan Lee
 
Engineering JavaScript
Engineering JavaScriptEngineering JavaScript
Engineering JavaScriptJim Purbrick
 

Similar to 連邦の白いヤツ 「Objective-C」 (20)

Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perl
 
Productaccess m
Productaccess mProductaccess m
Productaccess m
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
 
Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascript
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made Simple
 
Cross platform Objective-C Strategy
Cross platform Objective-C StrategyCross platform Objective-C Strategy
Cross platform Objective-C Strategy
 
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
 
Less ismorewithcoffeescript webdirectionsfeb2012
Less ismorewithcoffeescript webdirectionsfeb2012Less ismorewithcoffeescript webdirectionsfeb2012
Less ismorewithcoffeescript webdirectionsfeb2012
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
Engineering JavaScript
Engineering JavaScriptEngineering JavaScript
Engineering JavaScript
 

Recently uploaded

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

連邦の白いヤツ 「Objective-C」

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18. "initialize aMyObject " aMyObject initialize. " 30 setSize aSquare " aSquare setSize : 30. " + 4 " total := 3 + 4. min: other ^self < other ifTrue: [self] ifFalse: [other].
  • 19.
  • 20. // [receiver msg]; // msg:with: val = [receiver msg: arg1 with: arg2];
  • 21. // [receiver msg]; // msg:with: val = [receiver msg: arg1 with: arg2];
  • 22.
  • 23. #import <Foundation/Foundation.h> // @interface MyClass : NSObject { int val; } - (id)init; + (void)classMethod:(id)arg; // - (id)method:(NSObject*)arg1 with:(int)arg2; - (id)method:(NSObject*)arg1 param:(int)arg2; @end // @implementation MyClass + (void)classMethod:(id)arg { // some operation } - (id)method:(NSObject*)arg1 with:(int)args2 { return obj; } - (id)method:(NSObject*)arg1 param:(int)args2 { return obj; } @end
  • 24. #import <Foundation/Foundation.h> // @interface MyClass : NSObject { int val; } - (id)init; + (void)classMethod:(id)arg; // - (id)method:(NSObject*)arg1 with:(int)arg2; - (id)method:(NSObject*)arg1 param:(int)arg2; @end // @implementation MyClass + (void)classMethod:(id)arg { // some operation } - (id)method:(NSObject*)arg1 with:(int)args2 { return obj; } - (id)method:(NSObject*)arg1 param:(int)args2 { return obj; } @end
  • 25. // [MyClass classMethod:arg]; id obj = [[MyClass alloc]init]; // MyClass* obj = [[MyClass alloc]init]; // method:with: [obj method :arg with:10];
  • 26. // init - (id)init { self = [super init]; // if(self != nil) { val = 1; obj = [[SomeClass alloc] init]; } return self; }
  • 27. AlarmFake* f = [[AlarmFake alloc]init]; if( [f conformsToProtocol:@protocol(Alarm)] ) { // }
  • 28. @interface ObjcClass : NSObject{ @private int x_; @protected // int y_; @public int z_; @package // int w_; } @end
  • 29. ObjcClass* oc = [[ObjcClass alloc]init]; int z = oc->z_; // public int x = oc->x_; //
  • 30. ObjcClass* oc = [[ObjcClass alloc]init]; int z = oc->z_; // public int x = oc->x_; //
  • 31.
  • 32. @interface ObjcClass : NSObject - (void)print; @end @implementation ObjcClass - (void)print { NSLog(@"ObjcClass print:"); } - (void)private_print { NSLog(@"ObjcClass private_print:"); } @end void test() { ObjcClass* oc = [[ObjcClass alloc]init]; [oc print]; // ObjcClass print: [oc private_print]; // ObjcClass private_print:
  • 33. @interface ObjcClass : NSObject - (void)print; @end @implementation ObjcClass - (void)print { NSLog(@"ObjcClass print:"); } - (void)private_print { NSLog(@"ObjcClass private_print:"); } @end void test() { ObjcClass* oc = [[ObjcClass alloc]init]; [oc print]; // ObjcClass print: [oc private_print]; // ObjcClass private_print:
  • 34.
  • 35.
  • 36. #include <boost/shared_ptr.hpp> class CppClass{ public: CppClass(){} void print() const { std::cout << "CppClass::print" << std::endl; } }; @interface ObjcClass : NSObject - (void)print; @end @implementation ObjcClass - (void)print { NSLog(@"ObjcClass print"); } @end void boost_test(){ boost::shared_ptr<CppClass> p(new CppClass); ObjcClass* oc = [[ObjcClass alloc]init]; [oc print]; // ObjcClass print p->print(); // CppClass::print }
  • 37. MyObject* obj = [[MyObject alloc] init]; [obj method :arg with:10]; [nil method :arg with:10]; //
  • 38. MyObject* obj = [[MyObject alloc] init]; // [obj retain]; // NSLog(@"count=%d", [obj retainCount] ); // count=2 [obj release] ; // [obj release] ; // // MyObject* obj = [[[MyObject alloc] init] autorelease]; [obj retain]; //
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. - (BOOL)respondsToSelector:(SEL)aSelector; MySubClass* obj = [[MySubClass alloc] init]; if( [obj respondsToSelector:@selector(init)] ) { NSLog(@"YES"); }
  • 45. - (BOOL)respondsToSelector:(SEL)aSelector; MySubClass* obj = [[MySubClass alloc] init]; if( [obj respondsToSelector:@selector(init)] ) { NSLog(@"YES"); }
  • 46.
  • 47.
  • 48.
  • 49. @interface NSObject <NSObject> { Class isa; } - (id)init; + (id)alloc; - (void)dealloc; - (id)copy; + (Class)superclass; + (Class)class; - (IMP)methodForSelector:(SEL)aSelector; + (NSString *)description; + (BOOL)isSubclassOfClass:(Class)aClass @end
  • 50. - (BOOL)isEqual:(id)object; - (NSUInteger)hash; - (Class)superclass; - (Class)class; - (id)self; - (BOOL)isKindOfClass:(Class)aClass; - (BOOL)isMemberOfClass:(Class)aClass; - (BOOL)conformsToProtocol:(Protocol *)aProtocol; - (BOOL)respondsToSelector:(SEL)aSelector; - (id)retain; - (oneway void)release; - (id)autorelease; - (NSUInteger)retainCount;
  • 51.
  • 52. Class meta = [MySubClass class]; // MySubClass Class metameta = [meta class]; if( [meta isKindOfClass:[NSObject class]] ) { NSLog(@"YES"); }
  • 53. NSBundle* mainBundle = [NSBundle mainBundle]; NSBundle* moduleBundle = [mainBundle bundleWithPath : @"path"]; NSString* loadbleClassName = Class c = [moduleBundle classNamed : loadbleClassName ]; id = [[c alloc] init] autorelease];
  • 54.
  • 55.
  • 56. @interface MySubClass : MyObject { int x_; } @property int x_; @end @implementation MySubClass -(int)x_{ return x_;} // getter -(void)setX_:(int)x { x_ = x;} // setter @end MySubClass* obj = [[MySubClass alloc] init]; int xx= p.x_; p.x_ = 200;
  • 57. @interface MySubClass : MyObject { int x_; } @property int x_; @end @implementation MySubClass -(int)x_{ return x_;} // getter -(void)setX_:(int)x { x_ = x;} // setter @end MySubClass* obj = [[MySubClass alloc] init]; int xx= p.x_; p.x_ = 200;
  • 58. @interface MySubClass : MyObject { int y_; } @property int y_; @end @implementation MySubClass @synthesize y_; @end int yy= p.y_; p.y_ = 200;
  • 59. @interface MySubClass : MyObject { int y_; } @property int y_; @end @implementation MySubClass @synthesize y_; @end int yy= p.y_; p.y_ = 200;
  • 60.
  • 61.
  • 62. @protocol AlarmReq -(void)nowTime; @end // “<>” @interface MyClockReq : NSObject<AlarmReq> -(void)nowTime; @end @implementation MyClockReq -(void)nowTime{} @end
  • 63. @protocol AlarmReq -(void)nowTime; @end // “<>” @interface MyClockReq : NSObject<AlarmReq> -(void)nowTime; @end @implementation MyClockReq -(void)nowTime{} @end
  • 64.
  • 65.
  • 66. AlarmFake* f = [[AlarmFake alloc]init]; id<Alarm> f2 = f; if( [f2 conformsToProtocol:@protocol(Alarm)] ) { // }
  • 67. AlarmFake* f = [[AlarmFake alloc]init]; id<Alarm> f2 = f; if( [f2 conformsToProtocol:@protocol(Alarm)] ) { // }
  • 68.
  • 69. @protocol Alarm -(void)nowTime; @optional -(void)snooze; @end @interface MyClock : NSObject<Alarm> -(void)nowTime; //-(void)snooze; @end
  • 70. @protocol Alarm -(void)nowTime; @optional -(void)snooze; @end //-(void)snooze @interface MyClock : NSObject<Alarm> -(void)nowTime; @end @implementation MyClock -(void)nowTime { NSLog(@"nowTime"); } @end MyClock* a = [[MyClock alloc]init]; [a nowTime]; [a snooze]; //
  • 71. @protocol Alarm -(void)nowTime; @optional -(void)snooze; @end //-(void)snooze @interface MyClock : NSObject<Alarm> -(void)nowTime; @end @implementation MyClock -(void)nowTime { NSLog(@"nowTime"); } @end MyClock* a = [[MyClock alloc]init]; [a nowTime]; [a snooze]; //
  • 72.
  • 73.
  • 74.
  • 75. @interface MyObject : NSObject { int val; } - (void)bar; @end @implementation MyObject @end @interface MyObject(EventHandler) - (void)buttonClicked; @end @implementation MyObject(EventHandler) - (void)buttonClicked{ NSLog(@"calll buttonClicked"); } @end void category_test(){ MyObject* obj = [[MyObject alloc]init]; [obj buttonClicked]; // call buttonClicked }
  • 76.
  • 77. @interface NSString(matuura) - (void)whatsName; @end @implementation NSString(matuura) - (void)whatsName{ NSLog(@"akihiko matuura"); } @end void category_test(){ NSString* s = [[NSString alloc]init]; [s whatsName]; // akihiko matuura }
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90. @try{ if( ){ // errorcode = 1000; [NSException raise : @"Fatal Error occured" format : @"%d", errorcode]; // @throw [[MyException alloc]init]; } } @catch( NSException* ex ) { NSLog(@"name=%@, reason=%@",[ex name], [ex reason]); [ex raise]; // @throw; // } @catch( ... ) { NSLog(@"unknown exception"); } @finaly{ }
  • 91. @try{ if( ){ // errorcode = 1000; [NSException raise : @"Fatal Error occured" format : @"%d", errorcode]; // @throw [[MyException alloc]init]; } } @catch( NSException* ex ) { NSLog(@"name=%@, reason=%@",[ex name], [ex reason]); [ex raise]; // @throw; // } @catch( ... ) { NSLog(@"unknown exception"); } @finaly{ }
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100. void blocks_caller( void (^f)(void) ) { f(); } void blocks_test() { blocks_caller( ^(){ NSLog(@"test1");} ); blocks_caller( ^(){ NSLog(@"test2");} ); }
  • 101. Func<int, Func<int, int>> f = x => y => x + y; Func<int, int> fc = f(1); int x = fc(3); // 1 + 3 function< function<int(int)> (int) > f = [] (int x){ return [x](int y){ return x+y;}; }; auto fc = f(1); int x = fc(3); // 1 + 3
  • 102. void blocks_test() { typedef int (^add_function)(int); add_function (^f)(int) = ^(int x){ return Block_copy(^(int y){ return x+y;}); }; add_function fc = f(1); NSLog(@"blocks_test() fc=%d", fc(3)); Block_release(fc); }
  • 103.
  • 104.
  • 105.
  • 106. for (NSString *element in array) { }

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n