Best places to find iOS open source code

While working in building iOS I needed external helpers, control, etc..

Here are some of the most rich places to find helpers and controls for iOS development :

Continue reading “Best places to find iOS open source code”

The Power of Enumerations in Swift

Enumerations in Swift are very powerful tool, here are some of their advantages over normal Objective C enums :

  1. It can have functions and stored properties.
  2. It can implement protocols (as classes and structs)
  3. It can take non Integer values (like Strings )
  4. It can have what is called “associated values” which simply can make the enum take various types of values and handle them all

The best way to show all these features is some examples :

Continue reading “The Power of Enumerations in Swift”

Converting #define from Objective C to Swift

 

defined

In my current project we have a big constants file, It have two main things :

1- A lot of #define which defines constants used in all of the application.

2- A lot of #define also but have some functions inside it, something like
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

Since we are trying to convert to Swift we have a problem :

Some of these defines are convertible to Swift like normal string constant defines.

but other more complicated ones are not converted (like IS_OS_8_OR_LATER I mentioned earlier)

also BOOL defines are not converted, something like :

#define TestingBool TRUE

So I made a decision to convert this defines to Swift, then I got the second problem,

Continue reading “Converting #define from Objective C to Swift”

Swift and NSUserDefaults

200px-swift_logo_with_text-svg

One of the best things about Swift now that it is getting more and more support from the community, now you find very interesting helper libraries written in Swift.

In my current project I needed data structure which supports both fast search and fast insertion and have no duplicated values so I found the this great Swift library swift-algorithm-club which has lot of data structures and algorithms.

Happily I found the one data structure I was looking for : “Ordered Set” which satisfied all my need.

So I used the library in my project and it worked very well initially, but …

Continue reading “Swift and NSUserDefaults”

Objective C and Swift, the past and the future

200px-swift_logo_with_text-svg

As an relatively old iOS developer, I now see always the debate about which is better, Objective C or Swift.

Here is my thoughts about the subject :

  • Swift is the future, I think apple will kill objective c in couple of years.
  • Swift is far more modern than objective C.

Continue reading “Objective C and Swift, the past and the future”

How to find the best code on Github

github-mark

It have become now the De Facto standard for getting any code published as open source, also for developers it is the first place to look for helper libraries.

Saying that, there are thousands of repos containing great code on github, so how you can find the best ones suitable for your needs ?

Here is the procedure I follow :

1 – Search for proper keyword

for example here I am looking for good animation library to use in ios project

github8

Continue reading “How to find the best code on Github”

Why you should learn new programming language

image

As I think specialization is very important, both for your career and for the software industry as a whole, extending your perspective is also very important.
Continue reading “Why you should learn new programming language”

Podcasts for software engineers

I love to hear podcasts.
Here is my favorite list for software engineering

1-  Software Engineering Daily

sed_logo_updated

One of the best podcasts I have listened to,  Continue reading “Podcasts for software engineers”

Swift, Objective C dictionaries bad relation

Today I faced a very strange bug in our code,

The instruments shows a huge number of leaks originated from JSON parsing (using swiftyJSON).

At first I thought it was a normal retain cycle, since the problem only shows when setting the data source array with the result of parsing the json coming from the server, but unfortunately this wasn’t the problem.

After two days of inspecting the code I found that specific line of code which cause the problem

dataObject.content = content

where content is the defined as

let content = dic["content"]

and dic is NSDictionary

After another round of search I found the following post in swift mailing list describing similar problem

http://comments.gmane.org/gmane.comp.lang.swift.user/898

so I changed my code to this

let swiftContent = content as! [Dictionary<String, AnyObject>]
newsItem.NewsItem_content = swiftContent

and changed how the initial json dictionary created

so instead of

let dicItem = newsElementDict.dictionaryObject

I did

let dicItem = newsElementDict.rawValue as! NSDictionary

which have worked fine, And know I don’t get those leaks.

First Post

بسم الله الرحمن الرحيم

This is my first post in the blog 🙂

sun-shining-over-hills-1920x1080-wallpaper-10926