objective-c

How do I declare a child class as a property of a parent class to be used in related child classes?

I have a small class hierarchy where I would like to have a child class be a property of it's parent class and all related subclasses. Essentially, I have AbstractClass with a property of GroupClass. GroupClass is a child of AbstractClass. UsableObjectClass is a child of AbstractClass and uses GroupClass. If I do the following... #...

Get a UITableView to not scroll and grow within a UIScrollView

I need to create a screen that is similar to the one below. The only way I can come up with is to have a UIScrollView be the parent view. Then have a UIImageView and UILabels for the thumbnail and main text ("All3Sports"). For the sections like the phone numbers and home page, I thought I could have a UITableView and have it simply no...

How do I create an FSRef from a NSString containing a path?

I have a file system path in a NSString, but I need an FSRef for the system call I will be making. What is the best way to create the FSRef? ...

How do I send XML as the email body from a native iPhone app?

I am writing an app that ultimately wants to send some XML via email. I have the mailto/URL thing sussed, thanks to various links on the interweb, including Brandon and Simon Maddox. So I can send emails with the xml formatted using square brackets ([ ]), rather than the usual angle brackets (< >). But when I send angle brackets, with...

How far can you go using subclassing in objective-c?

In an iPhone app, I need to customize the look of a UINavigationController class. For instance, make the bar and font size bigger. My client really needs that, and bigger buttons aswell. So, instead of writing the class from scratch, I decided to subclass UINavigationController. My question is, can I customize any method or attribute's ...

pi in Objective C

I keep getting error in my iPhone programing when I try to use pi. I'm trying float pNumber = 100*cos(2 * pi * (days/23)); But i get errors that say: _pi, referenced from _pi$non_lazy_ptr I saw somewhere on the internet to use M_PI and it compiles but I don't think it gives me the correct calculation. When I try: float p...

Syntax error trying to use CGRect

I'm trying to add a subview to a tableview cell and of course using CGRect as part of that. However, I get a syntax error on build: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWi...

How do I look at an object in Xcode's debugger?

I have a simple question about debugging on Xcode and GDB. I often run into an error: unrecognized selector sent to instance 0x1081ad0 which makes the program load into GDB. Is there an easy way to examine what instance is located in that memory from GDB? ...

Repeating events on a gregorian calendar in Cocoa Touch

How would I set up a gregorian calendar in cocoa touch and set an event that will repeat every X days? Thanks ...

iPhone drag/drop

Trying to get some basic drag/drop functionality happening for an iPhone application. My current code for trying to do this is as follows: - (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:self]; self.center = location; } This ...

Point not in Rect but CGRectContainsPoint says yes

If I have a UIImageView and want to know if a user has tapped the image. In touchesBegan, I do the following but always end up in the first conditional. The window is in portrait mode and the image is at the bottom. I can tap in the upper right of the window and still go into the first condition, which seems very incorrect. - (void)t...

What does a hash/pound (#) represent in a format string?

I have some code to format a file size string: NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setPositiveFormat: @"#,##0.## bytes"]; Is the @"#,##0.## bytes" the same kind of format string as I'd use in stringWithFormat? What do the hash/pound symbols mean here? Thanks! ...

Static string variable in Objective C on iphone

Hi, How to create & access static string in iPhone (objective c)? I declare static NSString *str = @"OldValue" in class A. If i assign some value to this in class B as str = @"NewValue". This value persists for all methods in class B. But if I access it in class C (after assignment in B) I am getting it as OldValue. Am I missing somet...

Possible core-data bug: attributes named 'updated' don't work correctly?

I have a Core Data entity called Post. One of it's attributes is called updated and it is a date. The stored XML looks like this: <attribute name="updated" type="date">266164481.00000000000000000000</attribute> From this I concluded that the data is being stored correctly. When I read the data back the returned value is a NSCFNumber, ...

iPhone save the rotated UIImage

I want to save the rotated image to the photo library. I have a UIImageView in which the image is displayed. I used the below snippet to flip the image. The rotated image does get displayed since I transform the image view. But while saving the image I get the original image (not flipped). How do I save a flipped image? #define DEGREES_...

Objective C message dispatch mechanism

I am just staring to play around with Objective C (writing toy iPhone apps) and I am curious about the underlying mechanism used to dispatch messages. I have a good understanding of how virtual functions in C++ are generally implemented and what the costs are relative to a static or non-virtual method call, but I don't have any backgrou...

Consume WCF Web Service using Objective C on iPhone

I am having a hard time consuming a very simple (Hello World) WCF web service in my iPhone app. From what I have read, you must manually create the request message then send it to the web service URL. I was able to accomplish this on a .asmx web service, but not with a WCF service. How do I know the correct format of the request SOA...

Apple/iPhone Development IDE Preferences?

I'm going to do something I never thought I'd do... learn how to program for Apple hardware . After working in C, C++, C#, .NET, and even in the golden days of DOS (a little DOS4G/W memory extender in Borland Turbo-C, anyone?) and even as a kid, playing around with Atari 8-Bit Turbo-BASIC, I feel a little traitorous on multiple levels ...

Objective-C - Test for object instance being dealloced/freed

There's some way to test for an objective-c instance for being dealloced/freed (retain count == 0)?? By example, object A have a reference (pointer) to object B, but object B can be freed in memory low levels, how i test reference B to be sure it was dealloced?? @interface A : NSObject { B b; } @implementation A { - (void) someAc...

MVC Question... where to put code in Controller, and how to have UIView subclasses nest.

I have a feeling I've botched the design of my app from a high level. Right now, I have one Controller, the App Delegate, Two UIViews (one is a subclass of Scrollview) and one nib for the controller. In IB, I have set the class of the file owner to MusicGridController and then set the class of the UIView to MusicGridView. Thus, the...