iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

Why not enforce strict singleton application delegate object to use in NIBs?

I just ran myself round in circles, all coming down to having instantiated an app delegate object in a secondary NIB that wasn’t the NSMainNibFile. Amazing how having two app delegates kicking around means you have separate managedObjectContexts. Here’s a thought– could I make my application delegate class a singleton? And safely instantiate it in […]

How to set UIScreen Brightness Using UISlider in iOS4 from Setting.bundle

I am working one Feature of setting Brightness of mainscreen i search lots of googling got one code. UISlider *slider = (UISlider *)sender; float fBrightness = slider.value; [[UIScreen mainScreen]setBrightness:fBrightness]; But this code is worked Only iOS5 not in iOS4 when i am using this code in my apps i got warning and my app crash […]

Sorting of files while reading from document directory

I am currently reading the list of files present in my app document directory. NSString* documentDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSError* error = nil; NSMutableArray *myArray = (NSMutableArray*)[[[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentDirectory error:&error]retain]; But before showing the list of files i want to show the all files should be sorted properly. How can i do this?

How to remove top cell separator line

How do I get rid of the separator line appearing above the status bar? It’s hard to see in a screenshot, so I colored it red. I tried the code below for the first cell, but that didn’t work. cell.separatorInset = UIEdgeInsetsMake(0.f, 0.f, 0.f, 0.0f);

UITableView with fixed image background

Sorry but I found no clear answer on that. I have an iphone app with a tab bar and a UINavigationController in each tab. The interface is built with Interface Builder, and in the first tab there is a UITableView. I have prepared the xib with main view (A) containing a table (T) and an […]

Creating an array that contains only objects of a given class

Ok, so I have the code below (Objective-C FYI) and I was wondering if I want to create an NSMutableArray of c_data objects, how would I go about doing that? It’s sort of like declaring a List<c_data> cData in C#. @interface c_data : NSObject { double value; int label; int ID; } @property double value; […]

Call Objective C method from JavaScript with parameter

I succeed to call a Objective C method from a JavaScript method using the following ///javascript function hi() { CallNKitAction(“callFromJavascript className=TestCarouselViewController&index=”+index); } hi(); ////objective c -(void)callFromJavascript { NSLog(@”Before:%f”,refToSelf.carouselView.alpha); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.6f]; refToSelf.carouselView.alpha=0.0f; [UIView commitAnimations]; NSLog(@”After:%f”,refToSelf.carouselView.alpha); } but I don’t know how to call with a parameter. Can anyone help?

Wrong time from NSDateFormatter

I have a string that I want to parse the time from: NSString *longdate = @”Mar 27, 2011 8:38:38 PM”; I want to parse this date and output just the time portion w/ hours+minutes+am/pm: // First, convert our string into an NSDate NSDateFormatter *inFormat = [[NSDateFormatter alloc] init]; [inFormat setDateFormat:@”MMM dd, yyyy HH:mm:ss aaa”]; NSDate […]

How to access/print an NSMutableArray element from one view to another view?

I have an NSMutableArray named mArray in view1 and it stores some strings. Now I want to access/print/compare these elements in view2. Please guide me.

Convert Base64 GZipped string Objective-c or Swift

I received a string from a web service like this: CAAAAB+LCAAAAAAABADtvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//P1xmZAFs9s5K2smeIYCqyB8/fnwfPyJOp/PqTf6u/X8A1v85+wgAAAA= The source string was “EchoText” that compressed with Gzip then converted to Base64. I have to decode Base64 string at first then Unzip that using Gzip. How can I do in Swift (or Objective-C)? Edit: I found a good library for using Gzip: nicklockwood/Gzip […]