iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.
Why has NSNumber such strange retainCounts?
NSNumber* n = [[NSNumber alloc] initWithInt:100]; NSNumber* n1 = n; In the code above, why is the value of n’s retainCount set to 2? In the second line of the code, I didn’t use retain to increase the number of retainCount. I found a strange situation. Actually the retainCount depends on the initial number: NSNumber […]
Dynamically Updating a UILabel
I have a question regarding UILabels. I’m not even sure it is the right way to pull this off but I am trying to update a UILabel to display two numbers from 0 to 24 then loop back to zero and display the numer squence again. The catch is, it needs to update the UILabel […]
Getting a random object from NSArray without duplication
I have an NSArray with 17 objects, something like this: NSArray *objArray = [[NSArray alloc]initWithObjects: @”1″,@”2″,@”3″,@”4″,@”5″,@”6″ ,@”7″,@”8″,@”9″,@”10″,@”11″,@”12″,@”13″,@”14″,@”15″,@”16″,@”17″, nil]; and an int with a random number as follows: int random = arc4random()%17+1; I want to get a random object from this NSArray without it being a duplicate, even if I closed the app (maybe by using […]
How to use prepareForReuse method
I found this method called – (void)prepareForReuse. I read the document but i don’t understand how to use it. When i scroll my tableview, it gets stuck, or has slow scrolling and i intend to use prepareForReuse. Can someone please point me to a good tutorial or give me some sample code so i could […]
create uibutton subclass
I tried to subclass UIButton to include an activity indicator, but when i use initWithFrame:(since i’m subclassing uibutton i’m not using buttonWithType:) the button doesn’t display. Also how would i set the button type in this case?: my view controller: ActivityIndicatorButton *button = [[ActivityIndicatorButton alloc] initWithFrame:CGRectMake(10, 10, 300, 44)]; [button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; [button setTitle:@”Older […]
How does rand() work? Does it have certain tendencies? Is there something better to use?
I have read that it has something to do with time, also you get from including time.h, so I assumed that much, but how does it work exactly? Also, does it have any tendencies towards odd or even numbers or something like that? And finally is there something with better distribution in the C standard […]
What is the difference between '->' (arrow operator) and '.' (dot operator) in Objective-C?
In Objective-C what is the difference between accessing a variable in a class by using -> (arrow operator) and . (dot operator) ? Is -> used to access directly vs dot (.) isn’t direct?
How get a datetime column in SQLite with Objective C
How do you get a datetime column in SQLite with Objective C? I have a table with 4 fields: pk, datetime, value1 and value2. pk (primary key), value1 and value2 are integers so I am using: int value1 = sqlite3_column_int(statement, 2); int value1 = sqlite3_column_int(statement, 3); But what should I use for datetime?