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

Cant call delegate method from my protocol class

I have a protocol in one class: @protocol DataStorageManager – (void) saveFile; @end @interface DataManager : NSObject { id <DataStorageManager> delegate; } @property (nonatomic, assign) id<DataStorageManager> delegate; //methods @end and its implementation: @implementation DataManager @synthesize delegate; @end and I have another class which is the adapter between the first and the third one: #import “DataManager.h” […]

Detect if Device has GPS

How to detect if GPS is available? The iPod touch and iPad WiFi version don’t have GPS, they have something else based on WiFi. Anyway, how to know if GPS is available? Or how to detect iPod Touch or iPad Wifi model?

Take ScreenShot without Window

I’ve been studying Son Of Grab Apple demo and I’m really struggling to get a screenshot of screen without any window (only desktop, dock and menu bar). Does anyone knows how to do so?

Does an approximation of C++'s “const methods” exist for Objective-C?

Wondering if there’s any accepted practice for approximating C++’s ‘const methods’ in Objective-C. (new to the language from a C/C++ background) For instance: class Foo { public: void canChangeMemberVars(void); char* asString(void) const; }; “asString()” gets a const this pointer, so even if you go rogue and decide to muck around with the instance’s members it […]

Display Paragraphs in UITextView without \n

Is there a convenient way to format a rather long string with paragraphs in it (like below) to have it with \n in it so the textView will display the paragraphs as well? blah blah to @”blah\n\nblah” Thanks!

How to use method swizzle or something on subclasses

I has many UITableViewController subclasses in my app. Now i just needed to modify them all to add +1 row in all cases, and one simple equal row in all. I do not want to modify all of them by hand, better way seem’s to replace UITableViewDataSource method to modify values in way like: +(void)load […]

Why does not work changing UIButton text via dot syntax?

Is it possible to change UIButton title label text via dot syntax? The text is not changing if I do it via dot syntax: self.myButton.titleLabel.text = [NSString stringWithString:@”Nop”]; But this one does: [self.myButton setTitle: @”Yep” forState: UIControlStateNormal]; Text change works for pure UILabels, is UIButton a special case or something?

Objective C IBOutlets

In cases where multiple buttons call an IBOutlet, can the IBOutlet determine which button was pressed? edit: All fixed and wired up. key point: Object ID is not sender tag! Tag is a standalone value on the first page of the attributes. – (IBAction)buttonPressed:(id)sender { switch ( [sender tag] ) { case 109: NSLog(@”Button 1″); […]

How do I get the data from a finished `NSURLSessionDataTask`?

I know I can use dataTaskWithURL:completionHandler: to get the data in the completionHandler block, but that blocks the delegate methods from firing, and I need the didReceiveData: method to fire, as it’s how I configure my progress indicator. I’m completely at a loss how to get the downloaded data once it’s complete. What’s the delegate […]

Hooking end of ARC dealloc

Given the following simple implementation: @implementation RTUDeallocLogger -(void)dealloc { NSLog(@”deallocated”); } @end we run the following code under ARC: @implementation RTURunner { NSArray* arr; } -(void)run{ arr = [NSArray arrayWithObjects:[[RTUDeallocLogger alloc]init], [[RTUDeallocLogger alloc]init], [[RTUDeallocLogger alloc]init], nil]; NSLog(@”nulling arr”); arr = NULL; NSLog(@”finished nulling”); } @end we get the following log output: nulling arr finished nulling […]