public
Description: A lean-and-mean Ruby/ObjC bridge
Homepage: http://rubyobjc.com
Clone URL: git://github.com/timburks/rubyobjc.git
rubyobjc / test / testmemory.m
100644 40 lines (30 sloc) 0.733 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* testmemory.m
*
* Copyright (c) 2007 Tim Burks, Neon Design Technology, Inc.
* For more information about this file, visit http://www.rubyobjc.com.
*/
 
#import <Foundation/Foundation.h>
 
@interface MemoryTester : NSObject
{
    NSMutableArray *array;
}
 
- (void) createObjects:(int) n;
- (id) objectAtIndex:(int) i;
@end
 
@implementation MemoryTester
 
- (void) createObjects:(int) n
{
    array = [[NSMutableArray alloc] init];
 
    Class c = NSClassFromString(@"MyString");
    int i;
    for (i = 0; i < n; i++) {
        [array addObject:[[c alloc] initWithString:[NSString stringWithFormat:@"item %d", i]]];
    }
}
 
- (id) objectAtIndex:(int) i
{
    return [array objectAtIndex:i];
}
 
@end
 
void Init_testmemory() {}