Jul 18 2011

SBQueue - An Objective-C Queue for iOS 4.3

Published by Siegfried Bolz at 10:18 pm under iPhone



Because of the missing NSQueue, i have developed my own Queue equivalent. You can download it for free there (click). I have added some Unit Tests to make sure the Queue is working.

Below you can see the List of supported Queue-Methods:

SBQueue Methods

SBQueue Methods



Using it is very simple, just initialize the SBQueue and add Objects to it:

#import "SBQueue.h"

SBQueue *queue = [[SBQueue alloc] initWithQueueSize:10];
[queue addObject:[[NSString alloc] initWithString:@"Hello SBQueue"]];

If you have some improvements, feel free to drop a line below.

Technorati Tags: , , , , , ,


4 Responses to “SBQueue - An Objective-C Queue for iOS 4.3”

  1. ardenon 23 Nov 2011 at 7:44 am

    can i use fast enumeration on this queue?
    like

    SBQueue *queue = ;

    for ( id item in [queue getAllObjects])
    {

    }

    how to make fast enumeration available on your queue class as natural?
    like

    SBQueue *queue = ;

    for ( id item in queue)
    {

    }

  2. Billon 10 Jan 2012 at 10:20 pm

    Thanks for the nice queue class Siegfried.

    I’ve added fast enumeration to the class, but unfortunately the reply field on this site keeps stripping out important pieces of the code. If you would like to download it, you can find it at:

    https://www.katr.com/code/SBQueueFast.zip

    Now you can write:

    for ( NSString *str in myQueue ) {
    …do something
    }

  3. Siegfried Bolzon 11 Jan 2012 at 12:49 pm

    Great work, it is very useful. Thanks!

  4. Siegfried Bolzon 16 Jan 2012 at 8:26 pm

    I have updated my project with your code and added a test for the fast enumeration. It also contains the project-files for JetBrains AppCode 1.x

Trackback URI | Comments RSS

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Note: To submit your comment you have to preview it at first!