objective-c

Restore Backlight To Previous Level, iPhone

Hi there, I was working on my app recently and wanted to change the brightness of the backlight. I then wanted to restore the backlight level to it's original setting on exiting the app. Here is the code: #include "GraphicsServices.h" - (void) viewWillAppear:(BOOL)animated { NSNumber* bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR(...

Showing an alert in an iPhone top-level exception handler

I'm trying to display a UIAlertView in a top-level iPhone exception handler. The handler function looks like this: void applicationExceptionHandler(NSException *ex) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:[ex reason] ...

Line of code causes crash in instruments but not in Xcode

BOOL continueLoop; CGPoint thePoint; while(continueLoop != NO) { continueLoop = NO; thePoint = [self generateRandomLocation]; NSMutableArray *blocks = [self getBlocksForX:thePoint.x]; for(BlueBlock *block in blocks) { if(block.getBlockLocationY == thePoint.y) { continueLoop = YES; } } [blocks release]; } This cause...

Why do I get a "conflicting type" warning when I implement didSelectRowAtIndexPath:

Hello, I'm implementing the didSelectRowAtIndexPath: method in a tableviecontroller implementation. I get a "conflicting type" warning in my code. Everything seems to work, but the warning bugs me. The code in my implementation file is as follows. - (void *)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)ind...

XML parsing in objective-c

Hi all, I have a xml source and now i would like to present in my tableview. Source code for xml: <NewsML> <Catalog Href="http://www.afp.com/dtd/AFPCatalog.xml"/&gt; <NewsEnvelope> <DateAndTime>20091123T171818Z</DateAndTime> </NewsEnvelope> <NewsItem> <Identification> <NewsIdentifier> <ProviderId>afp.com</Provid...

a range of 2 old points with the 2 new points in multi touch

Hi there I developing an iPhone game and having some problem now, could anyone help me out ? I want to open a thing on the screen, the item in the centre of the screen, and I need 2 fingers to open it. Just put 2 fingers in and move horizontally to the certain points then let go, then the thing opens. I am making a range for the poin...

Keep header and implementation file in synch

I'm starting out on objective-C and so far I was under the belief that the .h and .m file should be in sync with-respect-to method details. However it seems I can add methods to the .m file without the addition of their sig in the .h file and it will still compile fine ! For e.g. this works in the .m file without any declaration in the ...

WebView Cocoa control crashing on window close.

I get a crash in WebEditorClient::clearUndoRedoOperations which is trying to access -[WebView(WebViewEditing) undoManager] when I close the main window of an NSDocument that contains a webview with a text editor in it. It only happens when there is an undo-able state. Seems like a bug in Cocoa, but I might be doing something wrong. Any i...

Objective-C - Comparing integers not working as expected

Hi everyone. So my problem is this: I am receiving a JSON string from across the network. When decoded (using SBJSON libraries), it becomes an NSDictionary that SHOULD contain a number of some sort for the key 'userid'. I say 'should' because when I compare the value to an int, or an NSINTEGER, or NSNumber, it never evaluates correctly....

Only first frame renders with OpenGL in Cocoa

I've been banging my head against a wall for a few days with this. I've read every document I could find and more on the subject of OpenGL and Cocoa. I'm just not understanding where my attempts break and the other ones don't. My code is listed below, it is fairly short as all I'm trying to do is render a rotating triangle. I am not new...

Objectiv C: how to check if variable is nsarray or nsmutablearray

Hello, how can i check a variable is NSArray or NSMutableArray??? Thanks ...

mask text inside uitextview/uiwebview

Hi folks, finally I choose to devote some time to find a way/implementation to mask text inside UITextView/UIWebView. By now what I'm able to do is: - add some custom background - add a uitextview/uiwebview with some text - add an UIImageView (with a covering png) or a CAGradientLayer to create a simple mask effect (*) Of course ...

What is the time format for APNS?

I want to show alert on a specific time on iphone using push notification.I have gmt +530 timezone in my local app.Suppose current time is 16:04:08 Gmt +530 and i want notification after one hour so currently I am converting it into UTC format and storing this time and alert message on server database. i want to know will i get the notif...

how to combine user voice and curently playing audio in iphone sdk?

Hello all, I want to create a karaoke like application.First tell me is it possible or not. How do i combine two sounds? suppose i am playing instrumental and want to record my voice so that i can create a new song using my voice. ...

Can we use pthread instead of NSThread in iPhone apps

Well I have an application that uses both Objective C & c++ but for portability reasons I have tried to use c++ as much as possible.... Now I am confronted with some problem that requires threads I was thinking of using pthread instead of NSThread.... is it Okay to use pthread... will Apple punish me for using it by rejecting my app on t...

Objective-C, class abstraction and accessing those variables

I have a lot of experience with java and c++ development, so classes and abstracting data is pretty easy for me. I only started objective C a short time ago, and i was mostly working with in class globals, and everything was progressing smoothly. I just decided to abstract a large portion of my code in an effort to make it less spaghetti...

How to empty cache for WebView?

Hi guys, I have a Webview that must load an image! When I upload this image I see every time the same image as before, and i must reboot my app to see the new image... I think is a cache problem..How can I solve that?? ...

display something on the screen everytime action made

hi everyone I have a problem not sure how to solve this. Hmm I am developing a game, a multi touch game, I already can make everything working fine, except a small issue that I want to show messages on the playing screen, each time the player makes actions. like his finger moves right the message says : "this finger moving right" nicely...

How to create a Firefox add-on using Objective-C on Mac OS X?

More precisely my goal is to create an add-on (or plug-in?) which is able to communicate with my main Cocoa application using something like the NSDistributedNotificationCenter. I need to be able to inject JavaScript code into the current webpage and get return values from the JS calls when my add-on receives the request to do so by my m...

Appending to NSString (immutable)?

Just trying a few things out and noticed that this works, it does compile, but I just wanted to check if it would be considered good practice or something to be avoided? NSString *fileName = @"image"; fileName = [fileName stringByAppendingString:@".png"]; NSLog(@"TEST : %@", fileName); OUTPUT: TEST : image.png Might be better writt...