Recently, I was working on an app with Xamarin where I had a long list of colors that the user can pick from. I created a Simple ListView inside my app to display all of the colors in a table. However, this approach presented some unexpected problems such as:
How do I display a preview of the color next to the text label in my ListView Cell?
How do I keep track of what colors are selected by the user?
How to display a checkbox next to a color once it’s selected?
If you have been reading my blog for the last couple weeks, you might have noticed that I have been using Xamarin to develop two mobile applications. When I wrote my initial impressions, I ran into multiple issues with getting the Android SDK to work and I also didn’t know how to use Xamarin Forms, and how to use the build in layouts, such as a StackLayout. Fast Forward a couple of weeks later, I got used to working with Android, working with the layout system and other features. In fact, I originally wrote a quick tutorial on how to use the ListView Control.
As many of you know, I’ve been contracted to create two mobile applications for some local small businesses. One common requirement for both of these applications is that the final product needs to be available on the iOS App Store and the Google Play Store. With this in mind, I figured I would try using Xamarin to create these apps. As I started working on these apps, I documented most of the initial thoughts via an older post on my blog. Since then most my problems have been resolved. However, I did notice it was hard to find good resources on how to build things using Xamarin Forms. I was able to find some old resources via some searches on YouTube, but I was not satisfied with the quality of the content. With this in mind. I wanted to take this opportunity to share what I have learned so far. Like my other Swift tutorials, we are going to start out small and work our way up. Let’s get started!
The ListView is a pretty common control in cross-platform mobile development. In Xamarin Forms, a ListView gets rendered out as a UITableView on iOS and a ListView in Android. You can create a ListView programmatically or you can use XAML. Once you have created your ListView you can access it in your code via its name property. Next, you have to assign an ItemSource to your ListView. In my case, I used a Generic List from the System.Collections.Generic Namespace. From there you populate your list with whatever data is going to be presented to the user. When your List is configured, set your List Object as the ItemSource property of your ListView. If you followed along with this post your app should compile fine and a ListView should show up on your device. If you encountered an error, check your code for errors as needed. Full code samples below. Happy Coding.
At the time of writing this post, I have been blogging about my software development career for over a month. Without a doubt, this has been an awesome career move for me. Ever since I posted my very first post I’ve gotten multiple compliments on the design of this website. These comments specifically surprised me the most, since I’m not a designer at all. However, I’m willing to work on the design of my apps until it looks good. I realize that I have not talked about iOS development lately. Don’t worry, I just finished the iOS app for Park-Lane Tobacconist. I think the app turned out quite well, and I definitely have plans to write about some new topics I learned during the process of making that app. I also plan to expand my writing in the area of mobile development to include Xamarin. I recently took on a cross-platform mobile application project, as a reason to check out the latest versions of the technology. I’m still in the early stages of this new project but my early thoughts on using cross-platform tools will be coming out in the next couple of weeks.
I have to admit, I’m short on time this week. Between going to school, working full time and side projects, I’m a very busy guy. Personally, I do not mind being so busy because I know this hard work is going to pay off in the long run. With that being said I figured it was time to write this post that I have been putting off for a while. This week I’m going to talk about all the gear I use to get things done. This list includes the hardware and software that I use in my daily workflow. Some of the items have an Amazon link in case you wanted to buy them for yourself.
If your new to mobile application development, one topic you should learn early on, is the concept of threading. Threading is a computer science term that handles the order of execution of tasks on the CPU. Threads are usually handled by the operating system. However there might be some tasks that can only be carried out on specialized threads created by the OS. To put things in context, consider the following example. Lets say I create an iOS application that uses a REST API to fetch data about upcoming concerts using location data. When you launch this application, the app freezes, takes a long time to load, and you see a white screen for more than 3 seconds. This is a common example of an app thats not optimized for the use of threads. As a result, you might receive complaints from your users saying that the app is slow or they delete your application all together. After a while, you decide to make some changes.
Upon inspection of your code, you find that your REST call is causing this slow down inside the ViewDidLoad method. you have to remember that in this case your code is being executed line by line. This means when your REST call is carried out, the CPU must finish getting your data before displaying it on screen. After reading this, you may be asking why does this happen? This happens because by default your application business logic and UI are loaded on the same thread called the main thread. Quick operations like simple math and string manipulation are perfectly fine on the main thread, but time consuming tasks like REST calls are not the best option. So how do we fix this? The simplest thing we could do is move this time consuming task to what is called the Background Thread. The Background Thread is a thread designed for complex operations. In return you leave the Main Thread open for UI changes. Here is some example code on how to make this happen.
If your reading this, then you stumbled on to my next post since writing my introductory post on New Years Day. If you have not read that yet, I strongly suggest you do that to learn more about why I’m blogging. Anyway, today’s post is all about some recent findings I discovered during the development process of the ParkLane iOS app. My use case is pretty simple and common for the platform. I have a login and sign up ViewControllers inside my app where the user can fill out some fields to create an account in our database or login into a existing one. However, I needed some kind of alert to pop up on the screen to tell a user if one of the following errors occurred:
Wrong Email
Wrong Password
Wrong Email and Password
As you can tell this presents a problem. I know Apple has something to solve this called a UIAlertView. Its pretty simple to use, it looks like this: let button2Alert: UIAlertView = UIAlertView(title: "Title", message: "message", delegate: self, cancelButtonTitle: "Ok", otherButtonTitles: nil)
// show alert on screen button2Alert.show()
I wasn’t worried to use this code because I’ve used it before, However Xcode presented me with this warning:
UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead
This left me puzzled, after doing some research this change occurred around the release of iOS 8 in 2014. After thinking about it some more, It must have been a change that I simply missed, and I take the blame for it. In a request to redeem myself I took out the old UIAlert code and replaced it with the newer UIAlertController.
After trying this new API, I have to say I like this better than the old UIAlertView. The newer framework seems like more work, but your getting more control over your alerts. Here is a quick code example to show you the difference.
If your familiar with how iOS views work the this seems pretty straight forward. I bet developers that don’t understand iOS or Swift can figure out what this code does. I also enjoy that the addAction method has a completion handler in order to execute some custom code when you tap a button on the alert.
Before I go, I realize that this first iOS post was pretty simple but do not worry. I have plenty of content coming up on more advance topics. So keep following my blog and be sure to follow me on Twitter to be alerted when new content is posted.
At the time of writing this post, its currently New Years Day. I figured today would be the perfect day to layout my vision for this site, and talk about some goals for my software development career in 2018. For easier reading purposes, I have broke down each of my goals into sections.
Why start a Blog?
This past summer, I read a book called ‘Soft Skills: The software developer’s life manual’ by John Sonmez. This book has changed my perspective on life, In return I begin to start the journey to take back my time and try to work for myself. This book explains how important it is to market skills as a software developer in order to get new clients and maybe a higher paying job. This book also mentions multiple times that a blog is a perfect medium to market my skill sets through blog posts and links to previous work. However with that being said, This isn’t my first time blogging. I’ve been trying to blog about various topics ranging from programming, tech news and video games for many years, but at the time I was very young and was not thinking about a long term career goal. This time it is a completely different perspective, I really want to be able to turn my skills into a sustainable business where I can be happy with the work I’m doing while taking back my time. Blogging into 2018 should help me do that while being able to market myself.
What are you going to be blogging about?
This is a very good question. While I was building this site, I often thought about what I’m going to write about. After some thinking I came up with the following ideas.
Documenting the progress on my side projects: At the time of writing this, I’m currently working on two side projects. Both of these projects I’m extremely passionate about and generally enjoy working on them. However, I think writing about these projects will help potential job recruiters and new developers some perspective on what technologies I know and use.
Documenting my experiences learning Swift again: It is no secret that I love Apple and the iPhone. When the Swift Programming language was announced in 2014. I was hooked. The announcement couldn’t not have come at a better time either, I was just about to graduate high school and start my first year of community college. With that in mind, I stayed up late reading Swift tutorials, watching Swift YouTube videos and reading the official Swift iBook. I made a few apps and submitted them on the App Store during that summer. The apps were not very good, but I was proud of them. However, I also wrote a lot of Swift code. (most of which I lost due to a hard disk failure :/). Since I started working full time, I haven’t had a chance to use Swift, Most of my day is spent in Visual Studio and C#. Don’t get me wrong, C# is one my personal favorite languages and tools like Xamarin make it possible to develop mobile apps in C#. However, through my experience, these tools are hard to use and I have ran into problems with them. With that being said, I can’t wait to start learning Swift again and to create better apps.
Software Development tips and tutorials: This is a pretty generic topic but I figured since developing software is a learning process. I figured I would create some content on how to accomplish certain tasks, tutorials on certain frameworks and languages and good tips for newer developers.
How often are you going to post?
This is a easy one! My goal is to post one blog post a week on any of the following topics outlined above.
If your still reading this, congratulations you have made it through my first blog post. Its only going to get better from here. If you have questions, comments and concerns please use the contact section of the home page or email me if you want to get a hold of me.