Skip to content

Instantly share code, notes, and snippets.

@Machx
Forked from anonymous/gist:4392908
Last active December 10, 2015 06:08
Show Gist options
  • Select an option

  • Save Machx/4392987 to your computer and use it in GitHub Desktop.

Select an option

Save Machx/4392987 to your computer and use it in GitHub Desktop.

Revisions

  1. Machx revised this gist Jan 8, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    @import Cocoa;
    import Cocoa;

    @export MyFramework.DataStructures;
    export MyFramework.DataStructures;
    //Objective-C Modules

    @class Queue : NSObject
  2. Machx revised this gist Dec 27, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -36,4 +36,4 @@ -(public id)dequeue
    @end

    //You could have a default rule that everything is public and
    //explicitly mark things as private
    //only have to explicitly mark things as private
  3. @invalid-email-address Anonymous created this gist Dec 27, 2012.
    39 changes: 39 additions & 0 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    @import Cocoa;

    @export MyFramework.DataStructures;
    //Objective-C Modules

    @class Queue : NSObject
    //implicitly because we are exporting group names we have a "namespace" of sorts
    //which is why this class doesn't have a prefix. Since we have modules now @class
    //can serve a different purpose than it currently serves

    @property(private,retain) NSMutableArray *storage;

    -(public id)init
    {
    self = [super init];
    if(self) {
    _storage = [NSMutableArray array];
    }
    return self;
    }

    -(public void)enqueue:(id)object
    {
    NSParameterAssert(object);
    [self.storage addObject:object];
    }

    -(public id)dequeue
    {
    if(self.storage.count == 0) return nil;
    id object = self.storage[0];
    [self.storage removeObjectAtIndex:0];
    return object;
    }

    @end

    //You could have a default rule that everything is public and
    //explicitly mark things as private