objective-c

iphone programming: access data, compare, display

Hi there, Would like some suggestion... for a navigation app, i am trying to transfer data around abit. Firstly, i am using NSString appDelegate to transfer data from navigation view 1 to navigation view 2. at navigation view 1 i have this: AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; if(appDelegate.s...

How can I be notified when a dispatch_async task is complete?

I have a asynchronous task like so: dispatch_async(dispatch_get_main_queue(), ^{ myAsyncMethodsHere; }); Is there a way to be notified when the background task is complete? Or to call a method upon completion? I've read through the documentation and have looked into dispatch_after, but it seems to be more designed to dispatch t...

What are Principal Attributes?

I'm reading the documentation on NSTableTview and I see the term Principal Attributes. What exactly are Principal Attributes? ...

presentModalViewController from a method returning void

I have two views and I want to present the second view from a method in the first view. My code works in an IBAction method, but not from one returning void. Is this a known issue, if so is there a workaround? My code is as follows (I already declared "scores" and -(void)win in FirstViewController.h): // In FirstViewController.m -...

Using UITapGestureRecognizer to show/hide menus

Hi, I'm trying to find a good way to make a tap show/hide my menus, in the same way as iBooks. I set up UITapGestureRecognizer to do this, but unfortunately it means then that none of the buttons on the screen work. I know I can use tapRecognizer.cancelsTouchesInView = NO; in order to allow the touches to go through, but then of cour...

Render UTF8 PDF correctly using CGContextDrawPDFPage

I have a japanese PDF document that I'm trying to render correctly on the iPad. I'm using the following code: CFURLRef pdfURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)pdfFilename, kCFURLPOSIXPathStyle, false); CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); CFRelease(pdfURL); CGPDFPageR...

UIWebView with Touch Event

Hi! I need to be able to catch touch events on a UIWebView and still be able to use the webview's contents (html links, etc...) I have subclassed UIWebView and implemented methods: - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSe...

iPhone SDK: Can't specify view to Navigation Controller

Hi everyone, I am working on my first iPhone app and making good progress. But there is one thing I just don't understand. When my app starts it displays a UIView with some functionality on it. This works fine. One of the buttons on that screen is supposed to load a new view (HistoryViewController) which contains a navigation controlle...

Switch Off iPhone Screen

Hi there, I am looking for a way to turn off the iPhone screen without the iPhone going to sleep. I don't really mind if turning the screen off is against apple rules. Would setting window alpha to 0 do the trick? Is there maybe some sort of boolean value I can change? If anyone has an ideas they would be much appreciated. Many thanks...

Objective C: Register file extension

Hello. I'm creating an app which needs to be opened if a user double clicks on a file with a certain extension.. how do i register the file extension with my app? and then read the contents?. E.G the file could have the extension words.ThisApp and it could be in XML Format.. how could i read that in objective c into an array? Objectiv...

How to display an NSString in NSLog

The following will compile but if run it will crash. -(void) testFunc : (NSString *)s{ NSLog(@"%@", s); } What's wrong with this code? I call the function like this: NSString *msg = @"This is a message"; [self performSelector:@selector(testFunc) withObject:msg afterDelay:0]; [msg release]; ...

Why we need to add property and synthesize?

Hello, I've read many books about Iphone dev. I'm new to objective c. Why we need to add property and synthesize? Can someone explain and relate it to real life story. eg: pointer - we call cop to catch criminal Thank you ...

Calling Objective-C methods

Let's say I have a method called foo. What's the difference between: [self foo]; and [self performSelector:@selector(foo)]; Are they the same? The first one seems so much easier, so why would you ever want to use the second one? ...

What's the MainWindow.xib nib file for ?

I am new to iOS developement, and i am trying to understand the whole cycle of iOS application developement, and i feel there's a missing part i just don't get it.. if the MainWindow.xib that is generated automatically by Xcode has a view that loads another xib/nib view inside it, then why we use it ? ...

How to write Portable C/C++/Objective-C++ code to target Apple iPhone/Mac OSX?

I'm working with some C/C++ code that runs on Win32 and also VxWorks. It uses #ifdef WIN32 to switch to platform specific implementations. I've been using the code on the iPhone and I want to update it and keep it as portable as possible, but I'm not sure what's the best practice. So far I've been using #ifdef __APPLE__ blocks. What ...

UIImageView not reflecting changed images

In my project, I made an animation for my UIImageView using some pngs. I recently swapped those pngs out for different images (with different file names) and removed the previous pngs to the trash. I updated my code to reflect the file name change but when I build my application, I still see the animated images that are not referenced in...

creating a reusable library in XCode 3.2

How do I create a reusable library/module in XCode 3.2? What I want to do is create a bunch of classes that provide certain functionality compile them into some kind of library, add such a library to an existing xcode project and use the classes in it. I come from .NET world so what I want to do is basically to create an equivalent of 'a...

Question about view controllers in the iPhone SDK

Hello. I will begin by saying that I'm 15 years old and from Sweden, so please excuse my English. I'm reading a book called Beginning iPhone 3 Developement - Exploring the iPhone SDK, by Dave Mark and Jeff LaMarche. I've read about navigation controllers and multiview applications, and now I want to create my own little app, a very simp...

How do I declare index=0 in .h file iPhone

// Declare index in Header.h index=0; - (IBAction)next { index++; // Set imageCount to as many images as are available int imageCount=2; if (index<=imageCount) { NSString* imageName=[NSString stringWithFormat:@"img%i", index]; [picture setImage: [UIImage imageNamed: imageName]]; } } Where do I decl...

Trying to change image using int

Hi, I have this code: - (IBAction)next { static int index = 0; // <-- here index++; // Set imageCount to as many images as are available int imageCount=16; if (index<=imageCount) { NSString* imageName=[NSString stringWithFormat:@"img%i", index]; [picture setImage: [UIImage imageNamed: imageName]]...