objective-c

Constants by another name

First off, I've seen this question and understand why the following code doesn't work. That is not my question. I have a constant, which is declared like; //Constants.h extern NSString * const MyConstant; //Constants.m NSString * const MyConstant = @"MyConstant"; However, in certain contexts, it's more useful to have this constant ...

Can somebody explain this Objective C method declaration syntax

I'm working through an iPhone development book* without really knowing Objective C. For the most part I'm able to follow what's going on, but there are a few method declarations like the one below that I'm having a bit of trouble parsing. For example: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) se...

Does UIGestureRecognizer work on a UIWebView?

I am attempting to get a UIGestureRecognizer working with a UIWebview which is a subview of a UIScrollView. This sounds odd but when I have the numberOfTouchesRequired set to 2 the selector fires, but when numberOfTouchesRequired is set to one the selector doesn't fire. Here is my code: UITapGestureRecognizer *tap1 = [[UITapGestureReco...

How can I build an app with multiple types of controllers?

How can I accomplish the following: When my app loads a UIView will show 4 buttons Clicking on a button will load a UITabBarController (not a UIView with a UITabBar) that can display multiple views. This seems challenging to me, because in order for me to use the UITabBarController I need to add this to the window's subview in my app...

Extract known pattern substring from NSString (without regex)

I'm really tempted to drop RegexKit (or my own libpcre wrapper) into my project in order to do this, but before I do that I want to know how Cocoa developers manage to do half of this basic stuff without really convoluted code or without linking with RegexKit or another regular expression library. I find it gobsmacking that Cocoa does n...

Network Connection NSNotification for OSX?

I simply need to have a notification post when a valid IP address is assigned. I have tried polling via SCReachability, but that seems to be inefficient. Any suggestions? This seems like it should be simple, but I've been struggling for several hours to get anything working. ...

How to handle duplicate symbol error from 3rd party libraries?

I have two 3rd party libraries that seem to use the same class. That should be fine but I'm getting this type of error when building: ld: duplicate symbol .objc_class_name_CJSONScanner in /Users/myappOne/TapjoyConnect/Frameworks/libTapjoyConnectSimulatorRewardInstall_Ads_Pinch.a(CJSONScanner.o) and /Developer/Projects/BuildOutput/Debug...

@dynamic property needs setter with multiple behaviors

I have a class that contains multiple user objects and as such has an array of them as an instance variable: NSMutableArray *users; The tricky part is setting it. I am deserializing these objects from a server via Objective Resource, and for backend reasons users can only be returned as a long string of UIDs - what I have locally is a...

UITableView does not scroll to cell

I am trying to scroll my tableview to the 2nd cell: [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionNone animated:NO]; I get the error: *** Terminating app due to uncaught except...

Quartz 2D animating text?

i have to animate text around a circle. The text will also scale up/down. Whats the best approach to accomplish this? (i am using Quartz 2D) My approach is: -- Calculate point using sin and cos methods. -- Move Pen there and draw text with alpha and size. -- Clear the screen -- Calculate next point using sin and cos methods. -- Move pe...

PDF or image loading on iPhone

Hello guys! Where I have to start if I want to load only a part of an image or pdf. So I would like to render only a part from a pdf file. How can this be done? ...

Animating a CALayer's mask size change

I have a UIView subclass which uses a CAShapeLayer mask on its CALayer. The mask uses a distinct shape, with three rounded corners and a cut out rectangle in the remaining corner. When I resize my UIView using a standard animation block, the UIView itself and its CALayer resize just fine. The mask, however, is applied instantly, which l...

strange GDB error unable to trace.

Hello all, I am getting this strange error in gdb and i'm unable to trace the exact line of code to trace the bug. Does someone knows about this type of bug? Here is what i get in gdb *** -[CALayer sublayers]: message sent to deallocated instance 0x911c2a0 (gdb) po 0x911c2a0 Program received signal SIGTRAP, Trace/breakpoint trap. 0x0209...

Are multiple lines in a header file allowed for text / strings?

I want to do this: #define kDescriptionText @"Some text here..." "...and more continued here." I've also tried: @"...and more continued here." Is this possible? Or must it all be on one looooooong line? ...

NavigationBar from UINavigationController not positioned correctly

So, my iPad program has a pseudo-split view controller (one that I implemented, not base SDK one), and was working correctly a while ago. It has the basic layout (UINavController for master, content view controller for detail on right), but I have it so the master view doesn't disappear when rotated into portrait view. Recently, I added...

Memory Leak in returning NSMutableArray from class

Hi I am quite new to Objective C for the iPhone, so I hope you wont kill me for asking a simple question. I have made an App that works fine, except that Instruments reports memory leaks from the class below. I use it to store settings from one class and then retrieve them from another class. These settings are stored on a file so they...

Cocoa Objective c : Auto Generate form

Hello, Is there a way i can generate form with TextField, Combo box etc in COCOA? We have certain data and i would like to generate form using given data. Thank you ...

how to expand the width of navigation bar in iphone?

is it possible how to expand the width of navigation bar in iphone? ...

iPhone accelerometer changing senstivity

Hi ! I'm trying to use the accelerometer to move a UIImage. I works well but my problem is that with my code self.character.center = CGPointMake(160+acceleration.x*175, 230-acceleration.y*175); my picture moves even on a stable surface because of the precision of the acceleration.x value. So I decided to use a workaround by multiply...

Optimize a views drawing code

Hi, in a simple drawing application I have a model which has a NSMutableArray curvedPaths holding all the lines the user has drawn. A line itself is also a NSMutableArray, containing the point objects. As I draw curved NSBezier paths, my point array has the following structure: linePoint, controlPoint, controlPoint, linePoint, controlPo...