objective-c

Question about Socket Streams on iPhone

I want to send a UIImage to a server with socket. I'm using this code from ADC: - (IBAction)searchForSite:(id)sender { NSString *urlStr = [sender stringValue]; if (![urlStr isEqualToString:@""]) { [searchField setEnabled:NO]; NSURL *website = [NSURL URLWithString:urlStr]; if (!website) { ...

Cocos 2d & CGPoint confusion in Landscape Mode

Hi,all, me again with another noob Cocos2d iphone question. I've set my Director to Landscape, but when I was looking at the coordinates of the 'Touch Event' it was still picking them up as though the screen was portrait. So they were basically reversed. x = 100, y = 50 should have been x = 50, y = 100 No biggie, it was easily ...

Accesing a UIView's member variable from another UIView

I have Three different views on iphone. I switch between different views successfully, but I want to access the 1st view's variable in second view's ViewDidLoad method but I can't get it so plz help me on that. ...

iphone: problem with events

MainViewController.h @class EventViewController; @class MainViewController; @interface MainViewController : UIViewController { EventViewController *eventViewController; MainViewController *mainViewController; //extern int i; @public NSString *titlegame; } @property (retain,nonatomic) EventViewController *eventViewContr...

Overwrite database or update (iPhone)?

I have a content based, read-only iPhone app. Users can select favorite topics, which I need to track. Some topics I'd like to make available between app updates through the App Store. I'll need to track if users have downloaded these particular topics or not until the App Store update is available. This approach will consist of two ...

How do I save current tab bar item when user quits and reload to that item when restart?

I want to save the current tab the user is in when he/she quits the application so I can load the application with that tab highlighted when the user re-enters the app. I presume I use the following method within my app delegate to save the current tab - (void)applicationWillTerminate:(UIApplication *)application but how do I gain acc...

Extending properties generated using @synthesize in Objective-C

Suppose I have an @property declared like this: @property (readwrite,retain) NSObject *someObject; And I synthesize it like this: @synthesize someObject = _someObject; This generates getters/setters for me. Also, according to the docs, the setter will have built in thread safety code. Now, suppose I want to add some code to the se...

TextField Example in Cocos2d

Can anyone please suggest me some links for using textField in cocos2d. I want to press on label, then textfield should get selected and i need to edit on that textfield. Please help me on this ...

Why do Cocoa apps use so much memory?

Even the standard blank-window Cocoa app that gets built when you make a new Cocoa project in Xcode uses almost 6 MB of memory. What's the reason for this? Is it possible to make an app use less, or does OS X simply manage memory differently for Cocoa apps? Not that I'm complaining. I know that performance "hardly matters anymore" (edit...

Beginner guide to OpenGLES on iPhone

Does anyone know a good beginners guide to using OpenGLES on the iPhone? I have found some but they all require assumed knowledge which I don't have. ...

Debugging "terminating Uncaught exceptions" in XCode

So my app is crashing, and I'm kind of at a loss on how to use XCode to debug. I found a forum on macforums about putting a breakpoint at "objc_exception_throw"... although I'm not really sure where to go from there. Any general guidelines for debugging in XCode? ...

NSArray (and other containers) behavior on dealloc

When Objective C containers are dealloc'd, do they release their references to the objects they contain or do I need to do that manually? ...

Do I have to specify a protocol if I want my class to have a delegate?

I'm new to Objective-C and development on Apple's platforms, but hopefully I can frame this question in an understandable way regardless :) I want to parse an XML feed for my iPhone app, and I decided instead of shoving all of the delegation methods from an instance of NSXMLParser into my view controller, I'd wrap this up inside of a Fe...

Limiting the number of objects in NSArrayController

I'm trying to create some kind of "Top 25" list in my app. I've used NSPredicate to filter the contents of the array controller but I want to limit the number of the results to just 25 objects. How could I do that? ...

How to add data for NSOutputStream?

I want to convert a UIImage to an NSOutputStream and send it to a server through socket. #import "Connection.h" @implementation Connection -(void) open: (NSString *) h : (int) p { strHost = h; intPort = p; [NSStream getStreamsToHost:objHost port:intPort inputStream: [receiveStream retain]; [sendStr...

Custom UISwitch & App Store approval

After doing some reading, I've found that you can customize the text and color on a UISwitch control. I'm curious if these methods will cause problems trying to get my app approved and included in the App Store. Sample code taken from iPhone Developer's Cookbook Sample Code: // Custom font, color switchView = [[UICustomSwitch alloc] i...

how do you copy an CALayer?

How to you make an NSArray full of multiple instances of a CALayer (all with the same frame, contents etc)? Background: CALayer takes a bit of overhead to create, so I would like to create a number of CALayers (all sharing the same properties) in the init method of a class (to be used later on in that class.) ...

iPhone Quartz2D: simple animation via delayed drawing

I'm trying to implement some very simple line drawing animation for my iPhone app. I would like to draw a rectangle on my view after a delay. I'm using performSelector to run my drawing method. -(void) drawRowAndColumn: (id) rowAndColumn { int rc = [rowAndColumn intValue]; CGContextRef context = UIGraphicsGetCurrentContext(); ...

Using directory with WebViewUI

I've got 60 or so web pages that I'd like to put into a directory. How can I modify this webview loadrequest to pull content from a directory? [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource:docPage ofType:@"html"]isDirectory:NO]]]; ...

How solve slow scrolling in UITableView

I test for first time in the real device, and after fixing some obvious performance problems I'm stuck in how do a smoth scrolling. This is what I do: The data is in sqlite I have a small array with the header I have in each header array the list of Id's from the Db Ej: Header A Ids= 1,2 Header B Ids= 3,4 I load lazy the c...