Intro to iPhone Programming
Posted in IPhone App Programming on April 30th, 2011 by AdminA nice video tutorial, that gives an introduction to iPhone programming.
A nice video tutorial, that gives an introduction to iPhone programming.
I recently spent some time with ELCImagePickerController. For those of you who’ve worked with UIImagePickerController, you might have noticed one of its major drawbacks: you can only select one photo at a time. ELCImagePickerController solves this issue by cloning the UI of UIImagePickerController, but with the added bonus of allowing you to select multiple assets. Collin Ruffenach (@cruffenach), who authored the the first version of the picker, has done an awesome job of making ELCImagePickerController look, feel, and behave like a native image picker. For this post I’m going to go through some recent improvements I made to ELCImagePickerController and pass along some lessons learned from working with the AssetsLibrary Framework.
This is my first foray into the AssetsLibrary Framework which was introduced with iOS 4.0. If you’re not already familiar with the framework, I highly suggest checking out both of these posts:
These should give you a solid picture of how to work with ALAssetLibrary, ALAssetGroup, and ALAsset.
One of the obvious changes I’ve made to the project is a reorganization of the code. Classes are broken out for clarity as you can see here:
Old Tree:

New Tree:

On major change to the project is how you present the new ELCImagePickerController. This is mainly due to an issue we uncovered with a redundant call to [super init] which was causing a substantial memory leak. Here’s the new way of showing the image picker:
ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] initWithNibName:@"ELCAlbumPickerController" bundle:[NSBundle mainBundle]];ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController]; [albumController setParent:elcPicker]; [elcPicker setDelegate:self]; ELCImagePickerDemoAppDelegate *app = (ELCImagePickerDemoAppDelegate *)[[UIApplication sharedApplication] delegate]; [app.viewController presentModalViewController:elcPicker animated:YES]; [elcPicker release]; [albumController release];
One interesting optimization I was able to make was on the loading of large albums which was previously taking several seconds. Since ALAssetGroup uses a block to enumerate assets, I just fire off a reloadTable call after a short delay:
// Show partial list while full list loads [self.tableView performSelector:@selector(reloadData) withObject:nil afterDelay:.5];
Then when the block is finished enumerating, it’ll call reloadTable as well. On an album with roughly 1500 photos, it was pretty tough to reach the bottom of the tableview before the block finished enumerating. So this is a pretty decent solution to the issue. Originally, I experimented with lazy loading the assets as the user scrolled through the table, but ultimately wasn’t able to get the performance I wanted out of it.
This release of ELCImagePickerController should perform faster, and with a smaller memory footprint than before. I hope you enjoy it.
You can follow me on twitter @matt_tuzzolo or get in touch with us at http://www.elctech.com
ps. for an extra bonus, check out [ELCAsset toggleSelection];
Matt Tubergen heads Recharge Studios, a wholly owned subsidiary of W3i that invests in the development and marketing/distribution of freemium mobile games. W3i is a market leader in distributing and monetizing apps with over 500 million apps distributed for W3i clients. Recharge Studios is actively seeking new investment opportunities, if you have a great idea for a game contact us.
In last week’s post we worked towards identifying ways to calculate the Revenue per Daily Active User as part of our Lifetime Value equation. This week, we look at ways to identify another variable in that equation: retention.
What is retention?
Retention is a key metric that speaks to how many users stick with your app day to day after initially being acquired. When attempting to calculate retention rates there are a variety of different ways to drill into the data and group users. Those groups of users, or vintages, may refer to the day they were acquired, the method in which they were acquired (offerwall, organic, advertising etc.)Or the source from which they were acquired (specific publisher source).
Calculating retention rates for mobile apps
Retention is calculated as an average of active users over time. We first have to calculate the daily retention rate on the first day a user is acquired, retention rates are 100%. Let’s say on day 1 100 users are acquired. On day two, 50 of those users are still active, making the retention rate on day two 50%. Now if only 25 of those users return on day three, the third day retention rate for that vintage would be 25%. To calculate the average retention rate for the entire application, we then take an average of all the daily retention rates for the period. . If we want to look at a more formulaic approach we could justify the following:
Retention Rate = Rate X (1 – Attrition Rate), so Day 1 it is (1 – Attrition Rate) and Day 2 it is (x% X (1-Attrition Rate))
For the sake of calculation, we used large, rounded numbers, often times when calculating the retention you’ll work with a larger data set and have a lower average.
Developers can also dive deep to understand specific retention rates by different user groups/vintages. By segregating by vintage, developers can start to identify different trends that will ultimately help make strategic decisions on user acquisition strategies. Consider the following:
User Group1 = Week 1 Users Acquired
Revenues1 = Week 1 Revenues Earned
Rev/User1 = User Group1 Rev/User for Week 1
User Group2 = Week 2 Users Acquired
Revenues1 = Revenues earned by this group in their Week 1
Rev/User1 = User Group1 Rev/User for Week 1
Note on retention rates
This post looks to identify, simply, how to calculate retention but its worth noting that projecting or forecasting retention rates may also come into play. Additionally, there are different ways to look at and interpret the data depending on what kind of information you’re trying to gain from your users.
Next week we’ll bring it all together to look at calculating lifetime value.
Do you have a question about freemium gaming or a topic you’d like us to explore? Let us know in the comments or catch us on twitter @rechargestudios or @w3i.
Freemium Game Blogs are published in partnership with the series on W3i’s corporate blog.
The 4th part of this series digs into rvalue references, perfect forwarding and associative containers.
Advanced STL covers the gory details of the STL’s implementation -> you will therefore need to be versed in the basics of STL, competent in C++ (of course), and be able to pay attention! Stephan is a great teacher and we are so happy to have him on Channel 9—the only place you’ll find this level of technical detail regarding the internals of the STL. There are no books. There are no websites. This is Stephan taking us into what is uncharted territory for most, even those with a more advanced STL skill set.
See the previous chapters on this Advanced STL series:
Part 1 -> shared_ptr and friends
Part 2 -> Algorithm optimization
Part 3 -> STL’s comprehensive correctness checks
New to STL? Watch the STL Introductory Series.
Microsoft WebMatrix is an exciting new product that makes the creation of custom ASP.NET Web sites possible without all the complexity of the full Visual Studio environment. Another advantage of Microsoft WebMatrix is the ability to easily purchase the proven applications from the Web Gallery. WebMatrix supports Web site development in both C# and Visual Basic. Unfortunately, the Visual Basic developers face an additional challenge of configuring the VB templates because Microsoft WebMatrix by default only has the C# templates configured.
In this walkthrough, I will demonstrate how to configure the Visual Basic templates in Microsoft WebMatrix.
Before you begin you need to download the code containing the VB templates. Also ensure that you have the administrator rights for the machine, as in this walkthrough you will be required to make changes to the “C:\Program Files\Microsoft WebMatrix\templates\” folder.
In this walkthrough we will cover the following topics:
You can configure the Visual Basic Templates in WebMatrix in the two simple steps as follows:
Step 1: Download and Install the Visual Basic Templates
Step 2: Configure the Visual Basic Templates
To download and install the Visual Basic Templates, follow these steps:




To use any of the templates, that you had installed in the previous step, to create the Visual Basic sites, you have to create an “Empty Site” and then copy the contents of one of these Microsoft Templates folders to the root of the Empty Web site. To create the “Empty Site” follow these steps:
fciv -add “Microsoft Templates” -r -type *.zip
<entry type=”application”>
<productId>BakeryVB</productId>
<title resourceName=”Entry_BakeryVB_Title”>Bakery VB</title>
<version>1.0</version>
<summary resourceName=”Entry_BakeryVB_Summary”>
Sample web site in VB showing a list of products that can be ordered.</summary>
<id>http://www.microsoft.com/web/webstack/bakery</id>
<updated>2010-3-24T18:30:02Z</updated>
<published>2010-03-24T18:30:02Z</published>
<longSummary resourceName=”Entry_BakeryVB_LongSummary”>
Sample web site in VB showing a list of products that can be ordered.</longSummary>
<link href=”http://microsoft.com/web/webstack/bakery” />
<images>
<icon>http://go.microsoft.com/fwlink/?LinkId=195175</icon>
</images>
<keywords>
<keywordId>Templates</keywordId>
</keywords>
<author>
<name>Microsoft</name>
<uri>http://www.microsoft.com/</uri>
</author>
<installers>
<installer>
<id>1</id>
<languageId>en</languageId>
<installerFile>
<fileSize>50</fileSize>
<installerURL>file://%ProgramFiles%\Microsoft WebMatrix\templates\BakeryVB.zip</installerURL>
<sha1>d40bbb4eb23bda648a95c0841e7d762d57d6c372</sha1>
</installerFile>
<msDeploy />
</installer>
</installers>
</entry>
Note: If you have downloaded the earlier, then you can copy the TemplateFeed.xml from that code. That code contains the updated TemplateFeed.xml file.
That’s it! You have now successfully configured the Visual Basic templates in the Microsoft WebMatrix. Now you will be able to create Visual Basic sites based on the site templates as easily as it is done with the C# sites.
You can find the full source code for the application here.
In this walkthrough, I will demonstrate how to convert an existing ASP.NET/jQuery application that consumes data from a Windows Communication Foundation (WCF) service to Silverlight.
Here are some topics that we will cover:
Before you begin you need to download the offline kit from the Firestarter Labs, to use the existing applications.
You can migrate an ASP.NET Web Forms application to Silverlight in three simple steps as follows:
Step 1: Explore the ASP.NET Web Forms application
Step 2: Migrate the ASP.NET application to Silverlight
Step 3: Call a WCF Service and Bind data
Let’s take a look at the code that we’ll be migrating. To start exploring the ASP.NET Web Forms application, follow the following steps:

Now let’s migrate the application to Silverlight. We’ll create a new Silverlight project, work with XAML, create a WCF service proxy to interact with the service, and design a user interface that mirrors the existing ASP.NET user interface.


<UserControl x:Class=”SilverlightCustomerViewer.MainPage”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″
xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″
mc:Ignorable=”d”
d:DesignHeight=”545″ d:DesignWidth=”550″ Width=”545″ Height=”550″>
<Grid x:Name=”LayoutRoot” Background=”White”>
</Grid>
</UserControl>
Note: The d:DesignHeight and d:DesignWidth attributes control the size of the design surface in the design mode. However, they don’t have any effect at runtime. The Height and Width attributes constrain the size of the Silverlight screen at runtime. If you don’t define the Height and Width attributes, Silverlight will automatically fill the entire area of its container.





Now let’s create a WCF service proxy that can be used to call an existing WCF service. We’ll also use a clientaccesspolicy.xml file to handle cross domain issues and bind data to controls.
Namespace CustomerService.Proxies
Note: This namespace is added so as to match the namespace of the new class with that of the namespace generated by the WCF proxy.
Partial Public Class Customer
Public ReadOnly Property FullName() As String
Get
Return FirstName & ” “ & LastName
End Get
End Property
End Class
Imports CustomerService.Proxies
AddHandler Loaded, AddressOf MainPage_Loaded
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim proxy = New CustomerServiceClient()
AddHandler proxy.GetCustomersCompleted, AddressOf proxy_GetCustomersCompleted
proxy.GetCustomersAsync()
End Sub
Private Sub proxy_GetCustomersCompleted(ByVal sender As Object, ByVal e As GetCustomersCompletedEventArgs)
CustomersComboBox.ItemsSource = e.Result
End Sub
Note: Once the WCF service proxy returns data it can be accessed through the GetCustomersCompletedEventArgs object’s Result property which is typed as an ObservableCollection of Customer. This collection is assigned to the ItemsSource property of the ComboBox.


Text=”{Binding ElementName=CustomersComboBox, Path=SelectedItem.CustomerID }”
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”158,225,0,0″ VerticalAlignment=”Top” Width=”219″ Text=”{Binding ElementName=CustomersComboBox, Path=SelectedItem.FirstName,Mode=TwoWay}” />
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”158,270,0,0″ VerticalAlignment=”Top” Width=”219″ Text=”{Binding ElementName=CustomersComboBox, Path=SelectedItem.LastName,Mode=TwoWay}” />
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”158,316,0,0″ VerticalAlignment=”Top” Width=”219″ Text=”{Binding ElementName=CustomersComboBox, Path=SelectedItem.CompanyName,Mode=TwoWay}”/>
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”158,366,0,0″ VerticalAlignment=”Top” Width=”219″ Text=”{Binding ElementName=CustomersComboBox, Path=SelectedItem.EmailAddress,Mode=TwoWay}” />
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”158,416,0,0″ VerticalAlignment=”Top” Width=”219″ Text=”{Binding ElementName=CustomersComboBox, Path=SelectedItem.Phone,Mode=TwoWay}” />
Note: Each TextBox binding has Mode=TwoWay added to it. This allows any change made to a TextBox control to be propagated back to the bound property automatically.
Dim proxy = New CustomerServiceClient()
Dim cust = TryCast(CustomersComboBox.SelectedItem, Customer)
cust.ChangeTracker.State = ObjectState.Modified
AddHandler proxy.SaveCustomerCompleted, Sub(s, args)
Dim opStatus = args.Result
Dim msg As String = If(opStatus.Status, “Customer Updated!”, “Unable to update Customer: “ & opStatus.Message)
MessageBox.Show(msg)
End Sub
proxy.SaveCustomerAsync(cust)
Dim proxy = New CustomerServiceClient()
Dim cust = TryCast(CustomersComboBox.SelectedItem, Customer)
cust.ChangeTracker.State = ObjectState.Deleted
AddHandler proxy.SaveCustomerCompleted, Sub(s, args)
Dim opStatus As OperationStatus = args.Result
If opStatus.Status Then
CType(CustomersComboBox.ItemsSource, ObservableCollection(Of Customer)).Remove(cust)
MessageBox.Show(“Customer deleted!”)
Else
MessageBox.Show(“Unable to delete Customer: “ & opStatus.Message)
End If
End Sub
proxy.SaveCustomerAsync(cust)
In this walkthrough you have examined an existing ASP.NET Web Forms application and supporting data access and service layers. You have now successfully migrated the existing functionality from the ASP.Net Web Forms application to Silverlight.
You can find the full source code for the application here.
Apple reaches 37.9 million users in the Unithed States, 59% more than Android.
AT&T activating more phones than Verizon.
United States Patent and Trademark Office has awarded Apple patents for the iPhone 4.
iOS 4 keeps a log of your location and stores it in a hidden file on your iPhone or iPad.
Reuters says iPhone 5 to arrive in September.
Read in this issue:
Data-encapsulation is key to the functionality of many high level or later generation programming languages such as C++ and Java. It is simply a means of creating “containers” called objects, and holding multiple variables of varying data types called member variables inside of those containers. C++ offers three methods of data-encapsulation; struct, union and class. This is where C++ become object oriented.
C++ Home
I am back with details on how to work with Panels, XAML, and Controls in Silverlight. In this walkthrough, we will see how to work with Panels, XAML, and Controls to create a Data-Driven Silverlight Interface.
During this walkthrough we will cover the following topics:
Before you begin, you need to download the offline kit from the Firestarter Labs to use the existing applications.
To work with Panels, XAML, and Controls follow these three simple steps:
Step 1: Create a Data-Driven Interface
Step 2: Create a Form Entry to edit the Interface Details
Step 3: Add a Menu using the StackPanel
In this step, we will see how to work with XAML, work with controls by adding a DataGrid, and work with the visual editor, known as the Cider editor, in Visual Studio. To create a Data-Driven Interface, follow these steps:
<Grid x:Name=”LayoutRoot” Background=”White”>
<Grid.RowDefinitions>
<RowDefinition Height=”Auto”/>
<RowDefinition Height=”Auto” />
</Grid.RowDefinitions>
</Grid>
<Grid x:Name=”LayoutRoot” Background=”White”>
<Grid.RowDefinitions>
<RowDefinition Height=”Auto”/>
<RowDefinition Height=”Auto” />
</Grid.RowDefinitions>
<TextBlock Height=”Auto” Width=”Auto” Grid.Row=”0″>
Contact Details
</TextBlock>
</Grid>
Note: The rows are indexed from the top of the panel to the bottom, beginning with zero.
xmlns:sdk=”http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk”>
<UserControl.Resources>
<DataTemplate x:Key=”ImageTemplate”>
<StackPanel>
<Image Source=”{Binding Image}” HorizontalAlignment=”Left” Height=”64″ Width=”64″/>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name=”LayoutRoot” Background=”White” DataContext=”{Binding Source={StaticResource Contacts}}”>
<Grid.RowDefinitions>
<RowDefinition Height=”Auto”/>
<RowDefinition Height=”Auto” />
</Grid.RowDefinitions>
<TextBlock Height=”Auto” Width=”Auto” Grid.Row=”0″ FontSize=”24″ HorizontalAlignment=”Left” VerticalAlignment=”Top” Margin=”8,8,0,0″>Contact Details</TextBlock>
<sdk:DataGrid AutoGenerateColumns=”False” Grid.Row=”1″ Height=”Auto”
Width=”Auto” HorizontalAlignment=”Left” Margin=”0,16,0,0″
x:Name=”ContactsDataGrid” VerticalAlignment=”Top” ItemsSource=”{Binding Collection}”>
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Binding=”{Binding Name}” Header=”Name”/>
<sdk:DataGridTemplateColumn CellTemplate=”{StaticResource ImageTemplate}” Header=”Image”/>
<sdk:DataGridTextColumn Binding=”{Binding Address}” Header=”Address”/>
<sdk:DataGridTextColumn Binding=”{Binding Email}” Header=”Email”/>
<sdk:DataGridTextColumn Binding=”{Binding PhoneNumber}” Header=”PhoneNumber”/>
<sdk:DataGridTextColumn Binding=”{Binding WebSite}” Header=”WebSite”/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</Grid>

Now let’s create a form entry to edit the interface details. In this step, we will see how to create a new UserControl and create a data entry form. To create a new UserControl, follow these steps:

<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”12,16,0,0″ Name=”textBox1″ VerticalAlignment=”Top” Width=”348″ Text=”Name” />
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”12,46,0,0″ Name=”textBox2″ VerticalAlignment=”Top” Width=”348″ Text=”Image Location”/>
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”12,74,0,0″ Name=”textBox3″ VerticalAlignment=”Top” Width=”348″ Text=”Address”/>
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”12,104,0,0″ Name=”textBox4″ VerticalAlignment=”Top” Width=”348″ Text=”Email”/>
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”10,134,0,0″ Name=”textBox5″ VerticalAlignment=”Top” Width=”350″ Text=”Phone Number”/>
<TextBox Height=”23″ HorizontalAlignment=”Left” Margin=”10,164,0,0″ Name=”textBox6″ VerticalAlignment=”Top” Width=”350″ Text=”Website”/>



xmlns:my=”clr-namespace:PanelsControlsLab”


Namespace PanelsControlsLab
Partial Public Class MainPage
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
Private Sub AddContactButton_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
Me.AddContactPanel.Visibility = System.Windows.Visibility.Visible
End Sub
Private Sub AddContactButton_Unchecked(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.AddContactPanel.Visibility = System.Windows.Visibility.Collapsed
End Sub
End Class
End Namespace
Note: There’s a shortcut to add an Event Handler. Select Checked in the Events property of the CheckBox control. Double-click the event to automatically generate the event handler (AddContactButton_Checked) for the CheckBox. Repeat this step for the UnChecked event and the AddContactButton_UnChecked event handler will be generated. In the AddContactButton_Checked handler, set the visibility of the EditContacts (PanelControlsLab) control to System.Windows.Visibility.Visible and in the AddContactButton_UnChecked handler, set it to System.Windows.Visibility.Collapsed.
<Border BorderThickness=”1″ Height=”227″ HorizontalAlignment=”Left” Name=”border1″ VerticalAlignment=”Top” Width=”372″>
<Border.BorderBrush>
<LinearGradientBrush EndPoint=”1,0.5″ StartPoint=”0,0.5″>
<GradientStop Color=”Black” Offset=”0″ />
<GradientStop Color=”#FF443B3B” Offset=”1″ />
</LinearGradientBrush>
</Border.BorderBrush>
</Border>


Now let’s add a menu using the StackPanel. In the StackPanel, the contained elements can be organized either vertically or horizontally by changing the Orientation property appropriately. In this case, we are going to add two more menu items (edit contacts and help) along with the Add new contact button and align the StackPanel horizontally. To add the menu items, follow these steps:
<StackPanel HorizontalAlignment=”Right” Margin=”0,8,8,11″ Orientation=”Horizontal”>
<ToggleButton x:Name=”AddContactButton” Content=”Add new contact” Checked=”AddContactButton_Checked” Unchecked=”AddContactButton_Unchecked” Height=”24″ Margin=”0,0,5,0″ />
<ToggleButton x:Name=”EditContactButton” Content=”Edit contact” Checked=”AddContactButton_Checked” Unchecked=”AddContactButton_Unchecked” Height=”24″ Margin=”0,0,5,0″ />
<Button x:Name=”HelpButton” Content=”Help”/>
</StackPanel>

In this walkthrough, you have learned how to create a Data-Driven Silverlight Interface using Panels, XAML, and Controls . You have now successfully added a data entry form to the existing project and created a menu using the StackPanel.
You can find the full source code for the application here.