Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

Tech Guides - Mobile

49 Articles
article-image-virtual-reality-and-social-e-commerce-rift-between-worlds
Julian Ursell
30 Jun 2014
4 min read
Save for later

Virtual Reality and Social E-Commerce: a Rift between Worlds?

Julian Ursell
30 Jun 2014
4 min read
It’s doubtful many remember Nintendo’s failed games console, the Virtual Boy, which was one of the worst commercial nose dives for a games console in the past 20 years. Commercial failure though it was, the concept of virtual reality back then and up till the present day is still intriguing for many people considering what the sort of technology that can properly leverage VR is capable of. The most significant landmark in this quarter of technology in the past 6 months undoubtedly is Facebook’s acquisition of the Oculus Rift VR headset manufacturer, Oculus VR. Beyond using the technology purely for creating new and immersive gaming experiences (you can imagine it’s pretty effective for horror games), there are plans at Facebook and amongst other forward-thinking companies of mobilizing the tech for transforming the e-commerce experience into something far more interactive than the relatively passive browsing experience it is right now. Developers are re-imagining the shopping experience through the gateway of virtual reality, in which a storefront becomes an interactive user experience where shoppers can browse and manipulate the items they are looking to buy ( this is how the company Chaotic Moon Studios imagines it), adding another dimension to the way we can evaluate and make decisions on the items we are looking to purchase. On the surface there’s a great benefit to being able to draw the user experience even closer to the physical act of going out into the real world to shop, and one can imagine a whole other array of integrated experiences that can extend from this (say, for example, inspecting the interior of the latest Ferrari). We might even be able to shop with others, making decisions collectively and suggesting items of interest to friends across social networks, creating a unified and massively integrated user experience. Setting aside the push from the commercial bulldozer that is Facebook, is this kind of innovation something that people will get on board with? We can probably answer with some confidence that even with a finalized experience, people are not going to instantly “buy-in” to virtual reality e-commerce, especially with the requirement of purchasing an Oculus Rift (or any other VR headset that emerges, such as Sony’s Morpheus headset) for this purpose. Factor in the considerable backlash against the KickStarter-backed Oculus Rift after its buyout by Facebook and there’s an even steeper hill of users already averse to engaging with the idea. From a purely personal perspective, you might also ask if wearing a headset is going to be anything like the annoying appendage of wearing 3D glasses at the cinema, on top of the substantial expense of acquiring the Rift headset. 3D cinema actually draws a close parallel – both 3D and VR are technology initiatives attempted and failed in years previous, both are predicated on higher user costs, and both are never too far away from being harnessed to that dismissive moniker of “gimmick”. From Facebook’s point of view we can see why incorporating VR activity is a big draw for them. In terms of keeping social networking fresh, there’s only so far re-designing the interface and continually connecting applications (or the whole Internet) through Facebook will take them. Acquiring Oculus is one step towards trying to augment (reinvigorate?) the social media experience, orchestrating the user (consumer) journey for business and e-commerce in one massive virtual space. Thought about in another way, it represents a form of opt-in user subscription, but one in which the subscription is based upon a strong degree of sustained investment from users into the idea of VR, which is something that is extremely difficult to engineer. It’s still too early to say whether the tech mash-up between VR, social networking, and e-commerce is one in which people will be ready to invest (and if they will ever be ready). You can’t fault the idea on the basis of sheer innovation, but at this point one would imagine that users aren’t going to plunge head first into a virtual reality world without hesitation. For the time being, perhaps, people would be more interested in more productive uses of immersive VR technology, say for example flying like a bird.
Read more
  • 0
  • 0
  • 1749

article-image-swift-missing-pieces-surviving-change
Nicholas Maccharoli
14 Mar 2016
5 min read
Save for later

Swift: Missing Pieces & Surviving Change

Nicholas Maccharoli
14 Mar 2016
5 min read
Change Swift is still a young language when compared to other languages like C, C++, Objective-C, Ruby, and Python. Therefore it is subject to major changes that will often result in code breaking for simple operations like calculating the length of a string. Packaging functionality that is prone to change into operators, functions or computed properties may make dealing with these transitions easier. It will also reduce the number of lines of code that need to be repaired every time Swift undergoes an update. Case study: String Length A great example of something breaking between language updates is the task of getting a string’s character length. In versions of Swift prior to 1.2, the way to calculate the length of a native string was countElements(myString), but then in version 1.2 it became just count(myString). Later at WWDC 2015 Apple announced that many functions that were previously global –such as count - were now implemented as protocol extensions. This resulted in once again having to rewrite parts of existing code as myString.characters.count. So how can one make these code repairs between updates more manageable? With a little help from our friends Computed Properties of course! Say we were to write a line like this every time we wanted to get the length of a string: let length = count(myString) And then all of a sudden this method becomes invalid in the next major release and we have unfortunately calculated the length of our strings this way in, say, over fifty places. Fixing this would require a code change in all fifty places. But could this have been mitigated? Yes, we could have used a computed property on the string called length right from the start: extension String { var length : Int { return self.characters.count } } Had our Swift code originally been written like this, all that would be required is a one line change. This is because the other fifty places would still be receiving a valid Int from the call myString.length. Missing Pieces Swift has some great shorthand and built in operators for things like combining strings - let fileName = fileName + ".txt" - and appending to arrays - waveForms += ["Triangle", "Sawtooth"]. So what about adding one dictionary to another? //Won't work let languageBirthdays = ["C" : 1972, "Objective-C": 1983] + ["python" : 1991, "ruby" : 1995] But it works out of the box in Ruby: compiled = { "C" => 1972, "Objective-C" => 1983 } interpreted = { "Ruby" => 1995, "Python" => 1991 } programming_languages = compiled.merge(interpreted) And Python does not put up much of a fuss either: compiled = {"C":1972, 'Objective-C': 1983} interpreted = {"Ruby":1995, "Python": 1991} programming_languages = compiled.update(interpreted) So how can we make appending one dictionary to another go as smoothly as it does with other container types like arrays in Swift? By overloading the + and += operators to work with dictionaries of course! func + <Key, Value> (var lhs: Dictionary<Key, Value>, rhs: Dictionary<Key, Value>) -> Dictionary<Key, Value> { rhs.forEach { lhs[$0] = $1 } return lhs } func += <Key, Value> (inout lhs: Dictionary<Key, Value>, rhs: Dictionary<Key, Value>) -> Dictionary<Key, Value> { lhs = lhs + rhs return lhs } With a light application of generics and operator overloading we can make the syntax for dictionary addition the same as the syntax for array addition. Operators FTW: Regex Shorthand One thing that you may have encountered during your time with Swift is the lack of support for regular expressions. At the time of writing, Swift is currently at version 2.1.1 and there is no Regular Expression support in the Swift Standard Library. The next best thing to do is to rely on a third party library or Foundation Framework's NSRegularExpression. The issue is that writing code to use NSRegularExpression to find a simple match is a bit long winded every time you wish to check for a match. Putting it into a function is not a bad idea either, but defining an operator may make our code a bit more compact. Taking inspiration from Ruby's =~ regex operator, let’s make a simple version returning a bool representing if there was a match: infix operator =~ { associativity left precedence 140 } func =~ (lhs: String, rhs: String) -> Bool { if let regex = try? NSRegularExpression(pattern: rhs, options: NSRegularExpressionOptions.CaseInsensitive) { let matches = regex.matchesInString(lhs, options: NSMatchingOptions.ReportCompletion, range: NSMakeRange(0, lhs.length)) return matches.count > 0 } else { return false } } (Take note of our trusty length computed property springing to action.) This time around there is no operator as of Swift 2.1 called =~. Therefore, we need to first define the symbol telling the Swift compiler that it is an operator that is infix taking objects on the left and right side, with a precedence of 140, and its associativity is left. Associativity and precedence only matter when there are multiple operators chained together, but I imagine most uses of this operator being something like: guard testStatus =~ "TEST SUCCEEDED" else { reportFailure() } Have fun but be courteous It would be wise to observe The Law of the Instrument and not treat everything as a nail just because you have a hammer in arm’s reach. When making the decision to wrap functionality into an operator or use a computed property in place of the canonical way of coding something explicitly, first ask yourself if this is really improving readability. It could be that you’re just reducing the amount of typing – think about how easily the next person reading your code could adapt. If you want to create even better Swift apps then check out our article to make the most of the Flyweight pattern in Swift - perfect when you need a large number of similar objects! About the author Nick Maccharoli is an iOS / Backend developer and Open Source enthusiast working at a startup in Tokyo and enjoying the current development scene. You can see what he is up to at @din0sr or github.com/nirma
Read more
  • 0
  • 0
  • 1718

article-image-android-your-mobile-platform-choice
Richard Gall
21 Mar 2016
2 min read
Save for later

Android: Your Mobile Platform of Choice

Richard Gall
21 Mar 2016
2 min read
It’s been a long week of argument and debate, strong words and opinions – and that’s just in the Packt office. But, now the votes have been counted we can announce that Android is the Packt customer’s mobile platform of choice. Across oour website poll and our Twitter poll, Android was the clear winner. Throughout the week, it also proved to be the most popular platform with customers, with sales of our Android eBooks exceeding those for iOS.  As you can see, our Twitter poll, delivered a particularly significant win for Android. Clearly there was a lot of love for Android. But what we really loved about the week was hearing some interesting perspectives from mobile developers around the world. This tweet in particular summed up why we think Android dominated the vote: Fundamentally, it’s all about customization – with Android you have more freedom as a developer, which, for many developers is central to the sheer pleasure of the development experience. Of course, the freedom you get with Android is only a certain type of freedom – and there are, of course trade-offs if you want the openness of such a platform. This article from October 2015 suggested that Android development is ‘30% more expensive than iOS development’ due to the longer amount of time Android projects take – the writers estimate that, on average, you write 40% more code when working with Android over iOS. But with new tools on the horizon likely to make Android development even more efficient (after all, think about what it was like to build for Android back in 2013!), it’s unsurprising that it should prove so popular with many developers. We’re celebrating Android’s win with an additional week of offers – which means you’ve now got another week to pick up our very best Android titles and get ready for a bright and exciting future in the mobile development world!
Read more
  • 0
  • 0
  • 1716
Visually different images

article-image-ios-9-speed
Samrat Shaw
20 May 2016
5 min read
Save for later

iOS 9: Up to Speed

Samrat Shaw
20 May 2016
5 min read
iOS 9 is the biggest iOS release to date. The new OS introduced new intricate features and refined existing ones. The biggest focus is on intelligence and proactivity, allowing iOS devices to learn user habits and act on that information. While it isn’t a groundbreaking change like iOS 7, there is a lot of new functionality for developers to learn. Along with iOS 9 and Xcode 7, Apple also announced major changes to the Swift language (Swift 2.0) and announced open source plans. In this post, I will discuss some of my favorite changes and additions in iOS 9. 1 List of new features Let’s examine the new features. 1.1 Search Extensibility Spotlight search in iOS now includes searching within third-party apps. This allows you to deep link from Search in iOS 9. You can allow users to supply relevant information that they can then navigate directly to. When a user clicks on any of the search results, the app will be opened and you can be redirected to the location where the search keyword is present. The new enhancements to the Search API include NSUserActivity APIs, Core Spotlight APIs, and web markup. 1.2 App Thinning App thinning optimizes the install sizes of apps to use the lowest amount of storage space while retaining critical functionality. Thus, users will only download those parts of the binary that are relevant to them. The app's resources are now split, so that if a user installs an app on iPhone 6, they do not download iPad code or other assets that are used to make an app universal. App thinning has three main aspects, namely app slicing, on-demand resources, and bitcode. Faster downloads and more space for other apps and content provide a better user experience. 1.3 3D Touch iPhone 6s and 6s Plus added a whole new dimension to UI interactions. A user can now press the Home screen icon to immediately access functionality provided by an app. Within the app, a user can now press views to see previews of additional content and gain accelerated access to features. 3D Touch works by detecting the amount of pressure that you are applying to your phone's screen in order to perform different actions. In addition to the UITouch APIs, Apple has also provided two new sets of classes, adding 3D Touch functionality to apps: UIPreviewAction and UIApplicationShortcutItem. This unlocks a whole new paradigm of iOS device interaction and will enable a new generation of innovation in upcoming iOS apps. 1.4 App Transport Security (ATS) With the introduction of App Transport Security, Apple is leading by example to improve the security of its operating system. Apple expects developers to adopt App Transport Security in their applications. With App Transport Security enabled, network requests are automatically made over HTTPS instead of HTTP. App Transport Security requires TLS 1.2 or higher. Developers also have an option to disable ATS, either selectively or as a whole, by specifying in the Info.plist of their applications. 1.5 UIStackView The newly introduced UIStackView is similar to Android’s LinearLayout. Developers embed views to the UIStackView (either horizontally or vertically), without the need to specify the auto layout constraints. The constraints are inserted by the UIKit at runtime, thus making it easier for developers. They have the option to specify the spacing between the subviews. It is important to note that UIStackViews don't scroll; they just act as containers that automatically fit their content. 1.6 SFSafariViewController With SFSafariViewController, developers can use nearly all of the benefits of viewing web content inside Safari without forcing users to leave an app. It saves developers a lot of time, since they no longer need to create their own custom browsing experiences. For the users too, it is more convenient, since they will have their passwords pre-filled, not have to leave the app, have their browsing history available, and more. The controller also comes with a built-in reader mode. 1.7 Multitasking for iPad Apple has introduced Slide Over, Split View, and Picture-in-Picture for iPad, thus allowing certain models to use the much larger screen space for more tasks. From the developer point of view, this can be supported by using the iOS AutoLayout and Size Classes. If the code base already uses these, then the app will automatically respond to the new multitasking setup. Starting from Xcode 7, each iOS app template will be preconfigured to support Slide Over and Split View. 1.8 The Contacts Framework Apple has introduced a brand new framework, Contacts. This replaces the function-based AddressBook framework. The Contacts framework provides an object-oriented approach to working with the user's contact information. It also provides an Objective-C API that works well with Swift too. This is a big improvement over the previous method of accessing a user’s contacts with the AddressBook framework. As you can see from this post, there are a lot of exciting new features and capabilities in iOS9 that developers can tap into, thus providing new and exciting apps for the millions of Apple users around the world. About the author Samrat Shaw is a graduate student (software engineering) at the National University Of Singapore and an iOS intern at Massive Infinity.
Read more
  • 0
  • 0
  • 1419
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $15.99/month. Cancel anytime