background preloader

Networking Tutorial for iOS: How To Create A Socket Based Server

Networking Tutorial for iOS: How To Create A Socket Based Server
If you're new here, you may want to subscribe to my RSS feed or follow me on Twitter. Thanks for visiting! Develop a socket-based iPhone app and server! Many iOS apps use HTTP to communicate to a web server, because it’s easy, convenient, and well-supported. However, in some cases you might find the need to go a bit lower level than HTTP, and communicate using TCP sockets to your own custom server. The advantages of doing this are several: You can send just the exact data you need to send – making your protocol lean and efficient.You can send connected clients data whenever you want, rather than requiring the clients to poll.You can write socket servers without a dependency of a web server, and can write in the language of your choice.Sometimes you just have to use sockets, if you are connecting to a legacy server! In this networking tutorial, you’ll get some hands-on experience writing an iPhone app that communicates to a TCP socket server using NSStream/CFStream. What is a socket? You see?

NSURLSession Tutorial Note from Ray: This is an abbreviated version of a chapter from iOS 7 by Tutorials that we are releasing as part of the iOS 7 Feast. We hope you enjoy! Each new iOS release contains some terrific new networking APIs, and iOS 7 is no exception. In iOS 7, Apple has introduced NSURLSession, which is a suite of classes that replaces NSURLConnection as the preferred method of networking. In this NSURLSession tutorial, you will learn what this new class is, why and how you should use it, how it compares to what’s been before, and most importantly: get practice integrating it into a real app! Note that this tutorial assumes you are familiar with basic networking concepts. Why Use NSURLSession? Why should you use NSURLSession? Background uploads and downloads: With just a configuration option when the NSURLSession is created, you get all the benefits of background networking. NSURLSession vs NSURLConnection “Wow, NSURLSession sounds complicated!” Now let’s use NSURLSession. Introducing Byte Club

Unit Testing Tutorial for iOS: Xcode 4 Quick Start Guide If you're new here, you may want to subscribe to my RSS feed or follow me on Twitter. Thanks for visiting! Learn how to set up your Xcode project to perform Unit Testing! Unit testing is great because it makes your life easier. Easier to deliver high quality code, and easier to make changes without fear of breaking something! But what might not be so easy is getting started if you’re new to unit testing – and that’s what this tutorial is all about! We’ll cover how to set up Xcode to use three different unit testing frameworks: OCUnit, which is the unit testing framework built into Xcode GHUnit, which is a third party framework with some extra cool features OCMock, which helps you write mock objects to aid tricky testing scenarios We won’t cover how to actually write test cases in this unit testing tutorial, but don’t worry – I’ll be covering that in my upcoming tutorial series on Test Driven Development for iOS! Getting Started with OCUnit GHUnit vs OCUnit Introducing OCMock Getting Started

How To Draw Graphs with Core Plot, Part 1 Use Core Plot to Draw Pie Charts, Bar Graphs, Scatter Plots and More! This is a blog post by iOS Tutorial Team member Steve Baranski, the founder of komorka technology, a provider of iOS development and consulting services. If you’ve ever wanted to include charts or graphs in your app, chances are you’ve considered the following two options: DIY. One option is to write all the drawing code yourself using Core Graphics/Quartz. Apple even has an example of this, in the SimpleStocks sample project.Buy it! But what if you don’t want to spend the time and effort to write it yourself, and don’t want to shell out a ton of money? Core Plot is an open-source plotting framework for both iOS and Mac OS X. In this 2-part tutorial series, we’ll show how you can use Core Plot to create pie charts, bar graphs, scatter plots, and more. To go through this tutorial, you need to have Xcode 4 installed, and a working knowledge of Objective-C, Interface Builder and storyboards. Adding Resources Wait a minute!

Unity 4.3 2D Tutorial: Animation Controllers If you're new here, you may want to subscribe to my RSS feed or follow me on Twitter. Thanks for visiting! Learn how to use animation controllers to move between a state machine of animations in this Unity 4.3 2D tutorial! Welcome back to our Unity 4.3 2D Tutorial series! In the first part of the series, you started making a fun game called Zombie Conga, learning the basics of Unity 4.3’s built-in 2D support along the way. In the second part of the series, you learned how to animate the zombie and the cat using Unity’s powerful built-in animation system. In this third part of the series, you’ll get more practice creating Animation Clips, and you’ll learn how to control the playback of and transition between those clips. This tutorial picks up where the previous part ended. Just like you did in Part 2, unzip the file and open your scene by double-clicking ZombieConga/Assets/Scenes/CongaScene.unity. It’s time to make that cat dance! Getting Started Transitions Editing Transitions Animating a Color

AFNetworking 2.0 Tutorial Learn how to use AFNetworking: an easy-to-use network API for iOS! Update 1/18/2014: Fully updated for iOS 7 and AFNetworking 2.0 (original post by Scott Sherwood, update by Joshua Greene). In iOS 7, Apple introduced NSURLSession as the new, preferred method of networking (as opposed to the older NSURLConnection API). Using this raw NSURLSession API is definitely a valid way to write your networking code – we even have a tutorial on that. However, there’s an alternative to consider – using the popular third party networking library AFNetworking. The latest version of AFNetworking (2.0) is now built on top of NSURLSession, so you get all of the great features provided there. AFNetworking is incredibly popular – it won our Reader’s Choice 2012 Best iOS Library Award. In this AFNetworking 2.0 tutorial, you will learn about the major components of AFNetworking by building a Weather App that uses feeds from World Weather Online. Getting Started From left to right, they are: Pretty easy, eh?

Grand Central Dispatch In-Depth: Part 2/2 If you're new here, you may want to subscribe to my RSS feed or follow me on Twitter. Thanks for visiting! Learn about concurrency in this Grand Central Dispatch in-depth tutorial series. Welcome to the second and final part of this Grand Central Dispatch in-depth tutorial series! In the first part of this series, you learned way more than you ever imagined about concurrency, threading, and how GCD works. In addition to all that, you enhanced the UX of the app through the timing of a prompt with dispatch_after, and offloaded the work from the instantiation of a view controller to perform a CPU intensive task with dispatch_async. If you have been following along, you can pick up where you left off with the sample project form Part 1. It’s time to explore some more GCD! Correcting the Premature Popup You may have noticed that when you try to add photos with the Le Internet option, a UIAlertView pops up well before the images have finished downloading, as shown in the screenshot below:

How To Write A Simple Node.js/MongoDB Web Service for an iOS App Learn how to create your own web service for your iOS app with Node.js and MongoDB! In today’s world of collaborative and social apps, it’s crucial to have a backend that is simple to build and easy to deploy. Many organizations rely on an application stack using the following three technologies: This stack is quite popular for mobile applications since the native data format is JSON which can be easily parsed by apps by way of Cocoa’s NSJSONSerialization class or other comparable parsers. In this tutorial you’ll learn how to set-up a Node.js environment that leverages Express; on top of that platform you’ll build a server that exposes a MongoDB database through a REST API, as such: The backend database rendered in a HTML table The second part of this tutorial series focuses on the iOS app side. The TourMyTown main view This tutorial assumes that you already know the basics of JavaScript and web development but are new to Node.js, Express, and MongoDB. A Case for Node+Mongo Getting Started

Related: