• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#import <Foundation/Foundation.h>
2
3@protocol MyProtocol
4
5-(const char *)hello;
6
7@end
8
9static int _class_int = 123;
10
11@interface BaseClass : NSObject
12{
13  int _backedInt;
14  int _access_count;
15}
16
17- (int) nonexistantInt;
18- (void) setNonexistantInt: (int) in_int;
19
20- (int) myGetUnbackedInt;
21- (void) mySetUnbackedInt: (int) in_int;
22
23- (int) getAccessCount;
24
25+(BaseClass *) baseClassWithBackedInt: (int) inInt andUnbackedInt: (int) inOtherInt;
26
27@property(getter=myGetUnbackedInt,setter=mySetUnbackedInt:) int unbackedInt;
28@property int backedInt;
29@property (nonatomic, assign) id <MyProtocol> idWithProtocol;
30@property(class) int classInt;
31@end
32
33@implementation BaseClass
34@synthesize unbackedInt;
35@synthesize backedInt = _backedInt;
36
37+ (BaseClass *) baseClassWithBackedInt: (int) inInt andUnbackedInt: (int) inOtherInt
38{
39  BaseClass *new = [[BaseClass alloc] init];
40
41  new->_backedInt = inInt;
42  new->unbackedInt = inOtherInt;
43
44  return new;
45}
46
47- (int) myGetUnbackedInt
48{
49  // NSLog (@"Getting BaseClass::unbackedInt - %d.\n", unbackedInt);
50  _access_count++;
51  return unbackedInt;
52}
53
54- (void) mySetUnbackedInt: (int) in_int
55{
56  // NSLog (@"Setting BaseClass::unbackedInt from %d to %d.", unbackedInt, in_int);
57  _access_count++;
58  unbackedInt = in_int;
59}
60
61- (int) nonexistantInt
62{
63  // NSLog (@"Getting BaseClass::nonexistantInt - %d.\n", 5);
64  _access_count++;
65  return 6;
66}
67
68- (void) setNonexistantInt: (int) in_int
69{
70  // NSLog (@"Setting BaseClass::nonexistantInt from 7 to %d.", in_int);
71  _access_count++;
72}
73
74+ (int) classInt
75{
76    return _class_int;
77}
78
79+ (void) setClassInt:(int) n
80{
81    _class_int = n;
82}
83
84- (int) getAccessCount
85{
86  return _access_count;
87}
88@end
89
90typedef BaseClass TypedefBaseClass;
91
92int
93main ()
94{
95  BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
96  TypedefBaseClass *typedefd = mine;
97
98  // Set a breakpoint here.
99  int nonexistant = mine.nonexistantInt;
100
101  int backedInt = mine.backedInt;
102
103  int unbackedInt = mine.unbackedInt;
104
105  id idWithProtocol = mine.idWithProtocol;
106
107  NSLog (@"Results for %p: nonexistant: %d backed: %d unbacked: %d accessCount: %d.",
108         mine,
109         nonexistant,
110         backedInt,
111         unbackedInt,
112         [mine getAccessCount]);
113  return 0;
114
115}
116
117