Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
11
Task/Classes/Objective-C/classes-1.m
Normal file
11
Task/Classes/Objective-C/classes-1.m
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// There are no class variables, so static variables are used.
|
||||
static int myClassVariable = 0;
|
||||
|
||||
@interface MyClass : NSObject
|
||||
{
|
||||
int variable; // instance variable
|
||||
}
|
||||
|
||||
- (int)variable; // Typical accessor - you should use the same name as the variable
|
||||
|
||||
@end
|
||||
17
Task/Classes/Objective-C/classes-2.m
Normal file
17
Task/Classes/Objective-C/classes-2.m
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
@implementation MyClass
|
||||
|
||||
// Was not declared because init is defined in NSObject
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
variable = 0; // not strictly necessary as all instance variables are initialized to zero
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (int)variable
|
||||
{
|
||||
return variable;
|
||||
}
|
||||
|
||||
@end
|
||||
5
Task/Classes/Objective-C/classes-3.m
Normal file
5
Task/Classes/Objective-C/classes-3.m
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Creating an instance
|
||||
MyClass *mc = [[MyClass alloc] init];
|
||||
|
||||
// Sending a message
|
||||
[mc variable];
|
||||
Loading…
Add table
Add a link
Reference in a new issue