A few days ago I read a STL Lambda Lounge post about Counting DNA Nucleotides. After solving the Nucleotides problem in Objective-C, I decided to solve a slightly different problem. I decided to count and print the number of times each character (assume ASCII text) appears in Moby Dick. I used the same data structure to solve both problems: an array of unsigned int values, where the array index represents the ASCII character and the value is the count.
Reading Moby Dick using Grand Central Dispatch
12345678910111213141516171819202122232425262728
// This function blocks until all characters are counted.voidCBRCountCharactersInFileAtPath(NSString*path,unsignedint*characters){// The dispatch_io_read is an asynchronous call. We use a semaphore to provide synthetic synchronization.dispatch_semaphore_tsemaphore=dispatch_semaphore_create(0);dispatch_queue_treadQueue=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);dispatch_io_tchannel=dispatch_io_create_with_path(DISPATCH_IO_STREAM,[pathUTF8String],0,O_RDONLY,readQueue,NULL);// SIZE_MAX means keep going until we reach EOF. dispatch_io_read(channel,0,SIZE_MAX,readQueue,^(booldone,dispatch_data_tdata,interror){if(done){// All bytes have been read. Let's notify that we are done.dispatch_semaphore_signal(semaphore);}elseif(data!=NULL){// As we read, we count.NSString*string=CBRStringFromDispatchData(data);CBRCountCharactersInString(string,characters);}});// Block the calling queue/ thread until the IO read completes (i.e. the channel is "done")dispatch_semaphore_wait(semaphore,DISPATCH_TIME_FOREVER);// What we open, we must close. dispatch_io_close(channel,0);}
The above code sets up and executes streaming file IO using Grand Central Dispatch. Now let’s look at the two functions named CBRStringFromDispatchData and CBRCountCharactersInString.
Here is the code used to create a NSString from a dispatch_data_t.
voidCBRPrintCharacterCount(unsignedint*characters){// This example only prints the "printable" characters. for(unsignedintcharacter=' ';character<='~';character++){NSLog(@"%c: %d",(char)character,characters[character]);}}
There are times when all I want or need from a Git repo are a handful files.
For example, I use the awesome git-completion and git-prompt scripts
included in the Git project. Thus, I don’t need the entire Git repo taking up space.
The “West” St. Louis CocoaHeads is now on Google+. If you are an iOS developer (or an aspiring iOS developer) in the St. Louis area, then you should join.
Bluetooth LE: Using iOS CoreBluetooth to communicate with “the Internet of Things”
By Jason Graves
BLE or Bluetooth ‘Low Energy’ is a fairly new wireless spec designed to connect us to world around us. This includes gathering data from embedded sensors like a thermostat or heart rate monitor, or controlling the lights in your house or unlocking the front door without a key. Apple’s CoreBluetooth framework has been around since iOS 5, but we are only now starting to see many new BLE enabled devices become available. We will cover some of the interesting uses of BLE and how to use CoreBluetooth to create your own apps that can communicate with these devices.
6:00pm - Meet/Greet
6:15pm - Bluetooth LE
7:30pm - Next Meeting Details, Questions / Discussions
St. Louis County Library Headquarters (East Room); (314) 994-3300; (1640 S. Lindbergh Blvd).
AppCode, by JetBrains, is what an IDE should be. All the tools I have come to know and love in a ‘grown-up’ IDE for the Objective-C and iOS platform. My productivity, and more importantly, my confidence to refactor, skyrocketed when I started using AppCode. Come learn about some of the powerful features, tips, tricks, and shortcuts AppCode has to offer the iOS developer.
Lighten the load on your teams with Jenkins
By JP Revel
If you’ve ever been part of a software project with a team, it often falls to one person to compile the project when it comes time to deliver. There are lots of problems with this approach. One solution is to set up a CI server, such as Jenkins (formerly Hudson). I will talk about the concept of CI, go over a sample setup, show some configuration and (hopefully) have Jenkins build a project for us.
6:00pm - Meet/Greet
6:15pm - iOS Tools Talk
7:30pm - Next Meeting Details, Questions / Discussions
St. Louis County Library Headquarters (East Room); (314) 994-3300; (1640 S. Lindbergh Blvd).
While apps with straightforward UI designs can often be implemented effectively using a single storyboard and GUI-based segues, this approach is less effective for large complex UI designs. This talk will discuss techniques for dividing an application’s UI into multiple storyboards and implementing programmatically-generated segues. We will discuss tab bar controllers, embedding sub-controllers into views, popover controllers, and navigation controllers. The talk will hopefully appeal to newbies and veterans alike.
6:00pm - Meet/Greet
6:15pm - UIStoryboards by Rick Aurbach
7:30pm - Next Meeting Details, Questions / Discussions
St. Louis County Library Headquarters (East Room); (314) 994-3300; (1640 S. Lindbergh Blvd).
The vast majority of developers don’t write unit tests against their applications. The typical design of many iOS applications and the iOS SDK can make it challenging to write tests. We will learn about some basic unit testing principles, mocking with OCMock, asserting with OCHamcrest, swizzling and even cheating with KVO, while keeping score with some helpful utilities like OCUnit2JUnit and code coverage with gcov.
6:00pm - Meet/Greet
6:15pm - Unit Testing Objective-C Applications by Jeff Roberts
7:30pm - Next Meeting Details, Questions / Discussions
St. Louis County Library Headquarters (East Room); (314) 994-3300; (1640 S. Lindbergh Blvd).
LLDB is the default debugger in Xcode on OS X. LLDB supports debugging Objective-C, C, and C++. We will discuss various aspects of the debugger, as well as look at how to utilize LLDB to effectively debug apps.
LLDB architecture
Various LLDB commands (setting breakpoints, setting watchpoints, thread control, etc.)
Using the LLDB Python bridge to “script” a debug session
6:00pm - Meet/Greet
6:15pm - LLDB by Brian Coyner
7:30pm - Next Meeting Details, Questions / Discussions
St. Louis County Library Headquarters (East Room); (314) 994-3300; (1640 S. Lindbergh Blvd).