My First App!

Hey! I’m Gagan, a soon to be high school senior in Michigan. This summer I’ve been learning to develop for the iOS platform. My brother was studying for the GMAT one day and complained about how he couldn’t find a timer that would beep every two minutes. So I thought, why not make one for him myself?

I had absolutely no background in Objective-C  or any C language for that matter, but I did take AP Computer Science where the focus was Java. I figured developing for the Apple App Store was well worth it considering the number of users they have. So from then on it was all about learning the iOS SDK and Objective-C.

I began by looking up resources and saw that many people recommended an iPhone and iPad development course on iTunes U, from Stanford University. For anyone that is interested in iOS, assuming you have at least a little programming background, that is the class to watch. The professor, Paul Hegarty, is excellent. He is easy to follow and does demos of nearly everything you learn about. I found it easiest to do the demos myself along with him. In a couple of weeks I had finished the class.

Both Objective-C and Java are object oriented programming languages, so honestly, learning the syntax of Objective-C was the hardest, but took nearly no time. My dad, a Computer Science Ph.D, always told me that once you learn one language it isn’t very hard to learn another. Guess he was correct.

I made the timer application for my brother, which took me about a day. We then started brainstorming what applications we could make to actually publish in the app store. We came up with a few ideas, picked one, and started working. The app, called Rap to Beats, was submitted to the app store a couple days ago. Check out this post on why we thought it was an app that needed to be made, and is one that people will actually use. I’ll talk about the programming aspect.

The application, in a nutshell, allows you to select an instrumental, record over it, and save it. Simple, right? I quickly realized that it was not as simple as that. Remember, I had just learned the basics of iOS development and I was no professional. Before I dive in, I want to mention that stackoverflow.com was probably my best friend throughout the entire development of the application. It’s easy to search for your problems, and everyone on the site is so strict about great questions and great answers that I usually found whatever I was having trouble with. If I didn’t, I simply asked the question myself, and within a couple of hours I would have an answer. It’s easy to use and is a great resource for any programmer.

The first problem that arose was that we wanted the application to have a LOT of beats. Not just four or five. We can’t have all of the beats pre-loaded, as the size of the app would then skyrocket. So I spent a couple days looking. I saw a few people talk about Amazon’s S3, and after checking it out I decided to try it. When searching for integration into iOS apps, I first found the ASI wrapper class. It is amazing, with many different features, but I should mention that no one should use it anymore. The author decided to stop development on it, and there are alternatives. Before I found out that work had stopped on it, I had already implemented it and got it working in my application.

It was as simple as

ASIS3BucketRequest *listRequest = [ASIS3BucketRequest requestWithBucket:bucket];
[listRequest setSecretAccessKey:secretAccessKey];
[listRequest setAccessKey:accessKey];
[listRequest startSynchronous];

to get a list of all songs in that bucket.

And as easy as

ASIS3ObjectRequest *request = [ASIS3ObjectRequest requestWithBucket:bucket key:path];
[request setSecretAccessKey:secretAccessKey];
[request setAccessKey:accessKey];
[request setDownloadDestinationPath:self.downloadPath];
[request startSynchronous];

to actually get the file from a bucket.

It turns out that Amazon has their own official SDK for this, so my next step is to change over to that. Now all we have to do to add a new song is add it in our Amazon account, and it’ll automatically show up in the application without an update.

The next problem was a quick fix. In the app, while recording, I play the song. The iPhone automatically makes it so the song plays out of the earpiece, resulting in a really quiet output to the user. A couple quick searches on stackoverflow told me that I needed to override it to play out of the speakers. It was as simple as adding the following lines of code:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
OSStatus propertySetError = 0;
UInt32 allowMixing = true;
propertySetError = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(allowMixing), &allowMixing);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
NSLog(@”Mixing (should be 0 or error): %ld”, propertySetError);
[[AVAudioSession sharedInstance] setActive:YES error:nil];

We then were working on saving a recording. The trouble was that I didn’t think I could actually save an audio recording in Core Data, and turns out that would have been a bad idea to even try. So the solution? Simply save the path of the recording in core data, and access the recording by fetching the path and initializing an audio player with that path. I want to mention that I found that it’s possible to store strings in a plist (which would just be the paths) rather than Core Data. But because Core Data is undoubtedly something I will need to use in the future I decided to use it and gain some experience with it. I want to point out that because XCode does so much of the Core Data set up for you, it’s actually very easy to implement.

Okay so we had made it so we can add a huge selection of beats, but what about allowing the user to add their own? I found out about file sharing. Simply enable it in your application, and everything in the document’s directory of the app is available to the user. That’s a way the user could actually get their recording somewhere different than the app. It also allows users to add their own files. So it was simple, each time the beats table is loaded, look in the document’s directory for a different song. If there is, show it. I know it’s in the documents directory, so playing it is simple.

So that’s it for the first iteration of our app! So much more to come. We want to allow users to record with headphones that have a microphone. We want to allow users to record over their iTunes music, but due to copyright laws we wouldn’t be able to allow them to save those recordings. My brother is rebuilding the entire user interface, and I’m excited about that. Please let us know if you want any features, or if you have made any instrumentals let us know if you want them in the application! Send us an email at SkyBrothersInc@gmail.com.

 

19 comments

  1. Pingback: Rap to Beats Available Now! | Aakash GuptaAakash Gupta
  2. Anonymous

    It’s actually a great and helpful piece of information. I’m happy that you shared this useful information with us. Please stay us up to date like this. Thank you for sharing.

  3. hermes online sale

    Thanks a lot for sharing this with all folks you actually recognize what you’re speaking about! Bookmarked. Kindly also seek advice from my website =). We can have a hyperlink exchange contract among us

  4. Luigi Fulk

    I just want to tell you that I am beginner to blogs and really liked your web-site. Likely I’m planning to bookmark your site . You actually come with fantastic writings. Many thanks for revealing your blog site.

  5. Birgit

    Hі tο every one, for the гeaѕon that I am genuinely keen of reading this
    website’s post to be updated regularly. It includes good information.

  6. Hilario Renshaw

    I feel this is among the so much vital info for me. And i’m satisfied studying your article. However want to commentary on few general things, The site style is great, the articles is in reality great :D. Just right process, cheers.

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>