Join/Login

Business Software

Open Source Software

For Vendors

Blog

About

More

Articles

Create

SourceForge Podcast

Site Documentation

Subscribe to our Newsletter

Support Request

For Vendors Help Create Join Login

Business Software

Open Source Software

SourceForge Podcast

Resources

Articles

Case Studies

Blog

Menu

Help

Create

Join

Login

Home

Browse

AMSerialPort

Code

AMSerialPort Code

Brought to you by: harmless-de

Summary

Files

Reviews

Support

Wiki

Code

Menu ▾ ▴

Browse Commits

Browse Files

[r49]: / trunk / SharedCode / AMStandardEnumerator.m  Maximize  Restore  History

Download this file

76 lines (62 with data), 1.6 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

//

// AMStandardEnumerator.m

//

// Created by Andreas on Mon Aug 04 2003.

// Copyright (c) 2003-2015 Andreas Mayer. All rights reserved.

//

// 2007-10-26 Sean McBride

// - made code 64 bit and garbage collection clean

// 2011-10-18 Andreas Mayer

// - added ARC compatibility

// 2011-10-19 Sean McBride

// - code review of ARC changes

#import "AMSDKCompatibility.h"

#import "AMStandardEnumerator.h"

@implementation AMStandardEnumerator

// Cover the superclass' designated initializer

- (instancetype)init NS_UNAVAILABLE

{

assert(0);

return nil;

}

// Designated initializer

- (instancetype)initWithCollection:(id)theCollection countSelector:(SEL)theCountSelector objectAtIndexSelector:(SEL)theObjectSelector

{

self = [super init];

if (self) {

_collection = theCollection;

#if !__has_feature(objc_arc)

[_collection retain];

#endif

_countSelector = theCountSelector;

_count = (CountMethod)[_collection methodForSelector:_countSelector];

_nextObjectSelector = theObjectSelector;

_nextObject = (NextObjectMethod)[_collection methodForSelector:_nextObjectSelector];

_position = 0;

}

return self;

}

#ifndef __OBJC_GC__

#if !__has_feature(objc_arc)

- (void)dealloc

{

[_collection release]; _collection = nil;

[super dealloc];

}

#endif

#endif

- (id)nextObject

{

if (_position >= _count(_collection, _countSelector))

return nil;

return (_nextObject(_collection, _nextObjectSelector, _position++));

}

- (NSArray *)allObjects

{

NSMutableArray *result = [NSMutableArray array];

id object;

while ((object = [self nextObject]) != nil)

[result addObject:object];

return result;

}

@end

SourceForge

Create a Project

Open Source Software

Business Software

Top Downloaded Projects

Company

About

Team

SourceForge Headquarters
225 Broadway Suite 1600
San Diego, CA 92101
+1 (858) 422-6466

Resources

Support

Site Documentation

Site Status

SourceForge Reviews

© 2025 Slashdot Media. All Rights Reserved.

Terms Privacy Opt Out Advertise

×
Want the latest updates on software, tech news, and AI?

Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.

Submit