objective-c

self.title is returning (null)

Using a navigation controller, I am pushing a new view and setting the title of it dynamically: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int countryIndex = [indexPath indexAtPosition: [indexPath length] - 1]; NSString *selectedCountry = [[countrysData objectAtIndex: countryIndex] obje...

XML parsing URL question

I am calling a web service to return XML data for states/provinces of countries. - (void)viewDidLoad { [super viewDidLoad]; NSString *titleForURL = self.navigationItem.title; NSString *path =[NSString stringWithFormat:@"http://myURL/AppointmentWS/CountryStateService.asmx/GetByCountryName?countryName=%@", titleForURL]; //NSString *path ...

Thread pools in CocoaTouch?

I have a set of tasks that are done repeatedly and instead of creating a new thread each time this user-invoked task needs to be performed, I'd like to use a thread-pool. In the typical flow to create a new thread, you have to setup an auto-release pool each time the thread entry point is invoked. It seems that the performance for this...

Core-Data iPhone: could not locate an NSManagedObjectModel

Hi, I am using Apple's CoreDataBooks sample project as a learning aid for core data. I modified the app so that when the app loads I show a menu page first - not the Books tableview (RootViewController). I have done the following: I created a menu page in interface builder (just a view with a button on it) The CoreDataBooksAppDeleg...

Multi-Threading question in Objective-C 2.0

Hi there, I have my main application delegate which contains a method that returns an object. This application delegate runs on the main thread. I also have a NSOperation that gets run on a different thread. As well as wanting to be able to call my app delegate method on my main thread sometimes, I also need to call it from my NSOperat...

Natural logarithm method for NSNumber and NSDecimalNumber

I've got some C# code that I'm converting to Objective-C. In C# I would call Math.Log(). I'm slowly learning that some people stick to C functions/types and only use NSNumber etc when they need to interop with Cocoa. Is there an equivalent for ObjC/Cocoa, or do I need to drop into C to do this? I need my code to be as accurate as possib...

Why does it feel like Interface Builder just gets in my way?

I'm very new to Cocoa for MacOSX, but I can't help but feel like I'm constantly fighting Interface Builder. My current situation is that I'm building an app that will have several custom controls and views. I started building the app in Interface Builder because it was initially very easy to drag things around and get them into the corr...

NSZombieEnabled doesn't report the type of object causing an EXC_BAD_ACCESS error

I have a crash that is happening deep within UIKit for some reason; an EXC_BAD_ACCESS error is happening something like 8 calls deep into a dismissModalViewController call. I tried enabling NSZombieEnabled for my executable, but the console log prints the same error regardless of whether or not zombies are turned on and i don't know whi...

Is is possible to define a class property in Objective-C?

To declare an instance property you can use a declaration similar to this: @property (readonly) int size; The property can later be accessed using the dot syntax: NSLog(@"The object has a size of: %d", objectInstance.size); However, I'd like to declare a class property so that, even without an instance, I can access it in this mann...

Writing an image out to a file in a cocoa app

I have a graphics editing cocoa app on Mac OSX that produces 32 by 32 square bitmaps, I need to programatically (I cannot use the interface builder at all) output this image to either a .jpg or .png. Can anyone link me to some good resources on how I might accomplish this task? ...

How to convert nsstring to nsdictionary?

I have gone through following question. http://stackoverflow.com/questions/998554/convert-nsstring-to-nsdictionary It is something different then my question. My question is as follows. NSString *x=@"<Category_Id>5</Category_Id><Category_Name>Motos</Category_Name><Category_Picture>http://192.168.32.20/idealer/admin/Picture/icon_bike2...

Sometimes I want to stop my Cocoa app from launching, how do I stop it in init?

I just want to quit as fast as possible, before the nibs are loaded. I tried [NSApp stop:self] but that didn't seem to work. Is there a better way than getting my process and killing it? (I know it's a weird thing to do. It's for a good reason.) ...

Scraping and Parsing a Wikipedia Page

Hey guys. I'm wondering if there are any existing libraries in or accessible from Objective-C that would allow me to scrape pages formatted like this one. Specifically, all of the dates and all of the text next to each date. If not, what would be the best way to go about doing this? Regular expressions? I heard that NSString might alread...

Replacing in NSString with wildcards / regular expressions - cocoa

NSString *x=@"\"/Sagar\' and \'Samir\' "; Now, I want to remove characters between these. \" / \' Intended output x = (should have) @"and \'Samir\'" So, Ms word give some options in find & replace, using wild card characters. ( just giving example ) Is it possible in cocoa? ...

How to store sensitive data (e.g. passwords, API keys) in Cocoa app?

I need to provide some passwords, API keys and similar sensitive data in my code. What are best practices in that regard? Hard-coded? SQlite? Some cryptographic framework? ...

Can I force a UITableView to hide the separator between empty cells?

When using a plain-style UITableView with a large enough number of cells that the table view cannot display them all without scrolling, no separators appear in the empty space below the cells. If I have only a few cells the empty space below them includes separators. Is there a way that I can force a UITableView to remove the separators...

How to Parse Some Wiki Markup

Hey guys, given a data set in plain text such as the following: ==Events== * [[312]] &ndash; [[Constantine the Great]] is said to have received his famous [[Battle of Milvian Bridge#Vision of Constantine|Vision of the Cross]]. * [[710]] &ndash; [[Saracen]] invasion of [[Sardinia]]. * [[939]] &ndash; [[Edmund I of England|Edmund I]] succ...

Objective-C And MetroWerks C/C++ IDE

Hello, I'm learning Objective-C and my friend have a real Macintosh IIci, that uses a Mac System 7(specifically 7.5.5 with a 68k processor) and I've installed Metrowerks C/C++ IDE(I think it's the version 1, but I don't know), but i didn't tested it, then i want to know one thing: It's possible to develop in Objective-C using NSObjects/...

iPhone: UITableView leaking like Titanic!

This is the code of my cellForRowAtIndexPath of my UITableView - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identificadorNormal = @"Normal"; UITableViewCell *cell; cell = [tableView dequeueReusableCellWithIdentifier:identificadorNo...

How to scale icons by zoom in a MKMapView?

How can I have the size of my icons scale with zoom in a MKMapView? As far as I can tell there is no way to do this? The only thing I can think of is to have the MKMapView a subview of some UIView, and catch all of the user input in this parent view, scale the images on zoom and relay to the subview. ...