[Swift] Extra argument ‘completion’ in call

xcodeIn iOS 8 SDK Development, the use of a closure to act on a response from the user when we ask them to use their twitter account produces the following compilation error:

Extra argument 'completion' in call

The error is misleading because there is no “extra argument” in the call to “accountStore.requestAccessToAccountsWithType“. Below the problem is on line #6. See it?

func reloadTweets() {
  let accountStore = ACAccountStore()
  let twitterAccountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)
  accountStore.requestAccessToAccountsWithType(twitterAccountType, options: nil, completion:
    { (granted: Bool, error: NSError) -> Void in
      if (!granted) {
        println("account access not granted")
      } else {
        println("account access granted")

It does not stand out and I only figured it out because I recognized the closure for ‘completion:‘ is a type-alias to ‘ACAccountStoreRequestAccessCompletionHandler‘, which is documented as:

typealias ACAccountStoreRequestAccessCompletionHandler = (Bool, NSError!) -> Void

Adding the exclamation mark (!) after NSError to force unwrap solve the error. The confusing part to me is NSError is not an optional type (at least it is not clear in the definition of NSError and I am not too familiar with Objective-C). Why does it need to be forced unwrapped? Would appreciate any further explanation on this from anyone watching.🙂

Posted in Programming, Swift | Leave a comment

[Swift] How to Pass By Reference via The Use of ‘inout’

xcode  When defining a function the keyword ‘inout‘ is used in front of the variable name to denote an in-out parameter, which sets up the function as a kind of “pass-by-reference” function. Note, this is not real pass-by-reference as the variable is still copied within the function, manipulated and the passed back out. 

What is an in-out parameter?
An in-out parameter is a parameter that has the keyword ‘inout‘ at the start of its definition. This parameter is like an alias or reference to the variable in the calling function. Changes made to the inout variable inside the function are retained when the function call completes. For example, we define our function as such:

Look at this function that swaps the values of two variables: swapCEO

func swapCEO(inout person: String, inout withPerson: String) {...}

Where the keyword ‘inout‘ denotes the parameter ‘person‘ and parameter withPerson of type ‘String‘ will have a value passed in and then passed out. The value passed out may or may not be changed, but should it be changed this will be perfectly acceptable.

When the swapCEO function is called, each of its two arguments must have prefixed an ampersand (&), like so:

swapCEO(&appleCEO, &microsoftCEO)

By prefixing an ampersand (&) to our arguments we are indicating the variables passed in may be modified.

Note: It is an error to use the keyword ‘inout‘ in a function definition but not prefix an ampersand(&) to an argument when that function is called.

Let’s See This in Action

We declare two variables to serve as place holders for the names of well known CEO’s. Time Cook the current CEO of Apple is stored in the variable appleCEO and Satya Nadella the current CEO of Microsoft is stored in the variable microsoftCEO.

var appleCEO = "Tim Cook"
var microsoftCEO = "Satya Nadella"

As previously mentioned, to swap the values of our two variables we simple call swapCEO and prefix the ampersand (&) to each of variables.

swapCEO(&appleCEO, &microsoftCEO)

We can now print the variables and see if this worked.

See the full execution from a Playground Session Below



This same concept may be used on any type, not just String, when you need a function to modify its variable parameters.

Posted in Devel | Leave a comment

[Swift] expressions require OS X 10.10 / iOS 8 SDKs or later

xcodeThe successor to Objective-C, Swift was announced by Apple in 2014. Instead of waiting I decided to start learning this language in order to add it to my “bag of tricks” as one of my professors would say. Considering I do not always have a laptop with OSX nearby, my work laptop is Windows, I scoured the internet for a way to have a command-line interface to swift. Something similar to tclsh for TCL or irb for Ruby. What I found was this, but it left me a bit hopeless:

`--> sudo xcode-select -switch /Applications/Xcode.app

``--> lldb --repl

Welcome to Swift!  Type :help for assistance.
println("Hello There!")

error: Swift expressions require OS X 10.10 / iOS 8 SDKs or later.

I guess the above may work in a later version of OS X. But, apparently I need OS X 10.10 or iOS 8 SDKs or later to run swift for the command-line. As of now OS X 10.9 is the latest out and it is what I have, see:

`--> sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.9.5
BuildVersion:	13F34

And, I also have Xcode 6.0.1, see:

`--> xcodebuild -version
Xcode 6.0.1
Build version 6A317

However, it was not until I stumbled upon @swiftLDN twitters page that I learned out how to run swift from the command line. All I needed to do was:

“–> xcrun swift -sdk ios8
<unknown>:0: warning: no such SDK: ‘ios8’
Welcome to Swift! Type :help for assistance.
1> println("Hello There!")
Hello There!

The message about “no such SDK” can be ignored. Apparently, anything can serve as a placeholder after “-sdk”.

Do not get me wrong. Swift works fine in Xcode from the GUI front-end for the current version of OSX and Xcode I have. However, just issuing xcrun swift from the command-line will not cut it just yet.

I hope that help anyone out there.


Posted in General-Tech | Leave a comment

[Futaba] 14SG Transmitter Programming Tips

14SGI came across this very useful video the other day, Futaba 14SG Radio Programming Tips. It is extremely useful for anyone with a Futaba 8FG [Super] or 14SG transmitter. I initially thought the two dials (LD and RD) were useful for pitch and throttle curves, but it just got in the way if they were not properly centered. I find it best to disable them both:




Other useful tips include:

  • Disabling Pitch and Throttle Curve Points
  • Disabling Trims
  • Simplifying Exponential Setup



Posted in General-Tech, Rc | 2 Comments

[Panasonic] Another Television For the Holidays? I Think Not!

panasonic-coverOn October 5th 2011 we purchased our very first flat screen television. After weeks of researching and speaking with colleagues I decided to go with Panasonic. We purchased from the Electronics Expo a Viera 50″ G25 Plasma (TC-P50G25). The whole family was impressed. It was jammed packed with features like an SD Card slot, DLNA for streaming multimedia from our NAS w/ built-in Ethernet to handle all that “Jazz” w/ stunning picture quality. We could not have it any better, but as luck would have it – four months later we had a hairline fracture due to our kids toy hitting the set. Our four year additional warranty – void! To save your eyes on further reading, customer service was the worst!


Called Panasonic and the store we purchased from (Electronics Expo) – no one would help!

A few months later, I figured – eh, why not? It was accidental damage, let’s just stick with Panasonic. But this time I decided to purchase from Amazon. We went with what was essentially a newer version of our previous set, a Viera TC-P50GT30. It was a bit thinner and I figured, eh why not get a screen proctor? So I did and purchased a TV Armor TV Screen Protector plexiglass. A good year went by and I felt really good about the purchase. A little less than two years and the darn thing would not turn on! However, we were greeted with the friendly “seven blinks of death”. Go figure! And this time I did not purchase the extended warranty – _all_types_of_expletives_here_ !! They don’t make televisions like they used to, eh? The older CRTs lasted decades.

This time around I am not in the mood to purchase another television and if it ends up happening it definitely will not be Panasonic.But, I think I may be able to save the day. Why? I picked up the Panasonic Plasma Technical Guide and Troubleshooting Flowchart and I am feeling lucky. On slide 48 of the pdf is the start of troubleshooting the 7 blinks failure. In short, the problem is either from a faulty SC, SU – SD (these are a pair) or SS board from what I have read and saw on you tube. I could be wrong.7-blinks


I did open up the set and located the boards that I think may be the problem as can be seen below:



The next step is to locate and purchase the necessary spare parts. Fingers crossed and I will post my findings good or bad. Say tuned!

Posted in General-Tech | 2 Comments

[RC Heli] How I got hooked on RC Helicopters

Devo 12S w/ case

Devo 12S w/ case

Devo 12S?, Mini-cp? Well, if you have been reading my blog for some time this is definitely a post out-of-the-norm, but I think you should no longer be surprised to see posts about rc helicopters here. I caught the “heli mania flu” while I had free time on paternity leave last month (thanks to my wife and grandparents!). The darn sickness will not go away – all I think about is developing the skills necessary to fly like this guy! It all started when my wife bought our five year old a 20$ cheap ccoaxial toy helicopter from the local store. After setting it up, testing it out and quickly mastering how to fly without crashing within a day or two I started reading about rc helicopters all over the net and watching all the YouTube video I could until I decided to buy one for myself.

This my friends is how I ended up with the “heli mania flu” and it will not go away! Well, not yet at least.🙂 Since my addiction I have purchased:

It all added up to a pretty penny, but I will not complain – not all the money you spend will be for a good cause! I would not have bought the phoenix simulator with the dx5e, but it was said it would not work with the DEVO 12S without a special adapter which I also ordered. Well, my son how has in own 5-channel transmitter to practice. However, to my surprise the DEVO 12S worked fine with the Phoenix Simulator software without a single hiccup and without the special adapter I ordered. I was able to fly all model helicopters and planes.

I look forward to more posts on the DEVO12S since I am completely fascinated with it. I plan to post the setup up configuring Phoenix simulator with the DEVO 12S and how to update the firmware so it can fly with non-Walkera helicopters. I am still a noob at flying rc helicopters, but below are some really useful information that helped increase my knowledge about the hobby, though I still have much, much more to learn!

For now I will stick with the simulator until I master my orientations, circuits, lazy-8s and all the other basic maneuvers. Let’s just say the mini cp will now be used for dissection. Either the mini cp is just too fragile or I crashed it way too many times!🙂

Check out this 11 year old, Tal Roglit, fly the Raptor G4 E720.

Posted in General-Tech | 1 Comment

[BSDA] Certification Holding Due to Expire in 2013

ImageWhen I took my BSDA certification exam back in August of 2008 it was on a whim. It was offered at Columbia University. I reviewed the exam objectives a few days before and passed the exam with flying colors! Since then, I have been using mainly Solaris 11 for hopes of passing the Solaris 11 Advanced Certification. So, I am sure I probably forgot a good portion of BSD Administration by now! It was on my mind recently that the BSDA exam would expire this year, but never gave it further thought. Coincidentally, the other day I received a pleasant surprise email from Dru Lavigne, the mother of BSD stating the my certification would expire after 2013.

In August and in Philadelphia, at the FOSSCON, the BSDA exam was offered, but I did not make it. However, I was surprised to learn that the BSDA can now be taken at select testing centers.

The BSD Certification has partnered with ISO Quality to offer the BSDA exam and will probably offer the BSDP once ready.

The fee for the exam is $150.00 US and can be paid for at the following link:

Unfortunately, once registered for the exam there is an additional fee to change the date. Be ware! Though, you have a year to book and take your exam once the fee has been paid.

Posted in *Nix | Tagged , , , , , , , | Leave a comment