#Blog

Blog articles on programming and problems focused on iOS and some web. I also write stories on my travel and hiking pursuits outside my work.

Sort an array of string containing numbers

by

By default, Sorting an array of string containing numbers is not sorted in natural order of numbers. They are sorted in natural order of string characters.

For example objects in array have property of type string which are all literal of numbers:


slot1.indexStr = “1”
slot2.indexStr = “14”
slot3.indexStr = “2”
slots = [slot1, slot2, slot3]


 slots = slots.sorted { $0.indexStr! < $1.indexStr! }

 1
 14
 2
 

It sorted alphabetically based on first character of string. What we want is to sort based on values of number.

CONTINUE READING


Hiking Satyavati Lake in Palpa

by

Our hike started from Sisne Khola. It’s few meters after or before Jhumsa Bridge if you are coming from Butwal or Tansen. There is a message board with direction too but in Nepali language so if you are a foreigner you could ask tea houses. They will guide you to the start of trail.

Trail is very easy to identify because mostly they are of stones so very hard to get lost. Kinda stairs made of stone. We followed it. First half of trails passes through forest. After forest we met off-road dirt path for small vehicles. Don’t follow it. Trail made of stones is just across the road and follow that. You want to hike through nature not dusty road.

CONTINUE READING


Hiking Ranimahal or Ranighat Palace in Palpa

by

This weekend I did a short hike to Ranimahal or Ranighat palace located in the banks of Kali Gandaki River. My first time visit to Ranighat was in Jeep vehicle. Journey was very unpleasant due to bumpy and dusty road so have your expectations set accordingly. Near the end of road trip - view of Ranimahal from distant was spectacular with river valley behind and river flowing nearby the banks. Landscape was picturesque. The insides are vacant. Once again don’t have your expectations too up. There isn’t much to the architecture of interiors that could be praised about.

Later I found information on short hiking route/trail to Ranighat. This peaked my interest. What Ranimahal lacks in interiors is compensated by the beautiful landscape around it. I planned the hike with my cousin. The hiking journey was memorable where we passed through clean rustic villages, corn fields, green slopes of hills, lush green forests, lots of creeks and small waterfalls. There were countless small creeks and streams on the trails. I could feel the nature and that is the experience all hikers needs.

CONTINUE READING


I bought a new camera

by

Photography and vlogging is my recent new hobby and the craft I am learning. Primary reason behind this new found interest is because I want to capture my hiking and outdoor travels other than my eyes. I want to share the experience with people.

Flower of a Coriander

Secondary reason is mental exercise that I recieve in a good way. I am from the field of software engineering and if you may believe or not it requires creativity to solve problems which is the most important skills required in any form of engineering. It’s an art too. No wonder why there are less good engineers among many in saturated market here. I learn new skills whether it is related to my work or if it is a new hobby. It keeps the flow of neurone active and sharp.

Remember new hobbies can be expensive in your wallet based on what hobby you choose so tread carefully and plan.

CONTINUE READING


inputAccessoryView ignores bottom Safe Area in iPhone X's

by

I have this neat view controller setup for my comments system. At the bottom of the screen is inputAccessoryView which will be fixed until interacted with to bring keypad up for user to post comments. When keypad is up view will be above it and if keypad is dismissed then view will stick at the bottom of screen.

To achieve this I override two methods of my UIViewController:


-(BOOL)canBecomeFirstResponder{
    return YES;
}

-(UIView *)inputAccessoryView{
    return commentInputView.contentView;
}

I am using custom xib and my custom input view is composed within the class.

It works fine except in iPhone with notch.

CONTINUE READING


Trekking to Nuwakot hill from Butwal

by

nuwakot-doban trail

This weekend I decided to go doban and stretch some extra kilo metres to my daily hike. My daily trail extends upto 5 km uphill and back downhill isn’t a big stress, credits to the fresh air, smoky mountains and chirping of birds that are enough to heal my body and soul.

I decided to backpack for the weekend hike to cover small settlement called Doban beside Tinau river.

There is an official short hike trail from near Fulbari zoo in Butwal. Tourist and locals use it. I wanted to walk along the peak of hills and embrace the scenic beauty from top. Hence I took long path instead. Nuwakot village was my first destination from where Doban was 3 Km downhill. I started my journey from northwest outskirts of Butwal city, somewhere between Belbas and Jeetgadhi.

CONTINUE READING


Auto sizing UICollectionViewCell of UICollectionView fails in iOS 12

by

The content of my UICollectionView flows in horizontal direction. Height of items are fixed but width of each are dynamic based on the length of text. For this example I am using only UILabel in my UICollectionViewCell. My UICollectionViewCell is custom xib.

These are the constraints I have applied to UILabel:
  • Leading : 0
  • Trailing : 0
  • Top : 0
  • Height : 44

CONTINUE READING


Blurry Pixel Font in SpriteKit bug

by

It's amazing how modern Pixel Art captures the true simplicity yet also expressing creative masterpieces. I find so much solace staring at the world presented by games like Stardew Valley and Kynseed.

In my spare time I am making 2d pixel art game for iOS and macOS for my hobby. I found a free pixel art font called PixelDigivolve to use it for my texts. There was this behaviour that caught my attention where font was being rendered very blurry. The edges were not sharp.

SpriteKit has filtering mode called nearest-neighbour for rendering textures.

CONTINUE READING


Sort NSArray of custom objects with more nesting

by

Sorting an array of custom objects is fair simple. NSSortDescriptor works awesome for this. Lets see an example:


@interface Parent : NSObject
@property(strong, nonatomic) NSString *name;
@end
NSArray *arrayOfParents = @[parent1, parent2];

If I want to sort array of parents by their name then I would use something like:

CONTINUE READING


drawViewHierarchyInRect vs renderInContext

by

I came across very curious problem whose cause I couldn’t have come to know about it without serious debugging because this was something that didn’t catch my attention. I had a task that required capturing snapshot of UIView with hierarchy of subviews and perform few interactive transformation animations on view immediately after - giving feeling of instant multitask. Delay should have been negligent for naked eyes or tolerant but it wasn’t.

CONTINUE READING


Recommended posts