objective-c

objective-c over-releasing in dealloc

Is mystring over-released? -(void)dealloc { [mystring release]; [mystring release]; [super dealloc]; } I assume this will not based on [nil release] does nothing: -(void)dealloc { [mystring release]; mystring = nil; [mystring release]; [super dealloc]; } -EDIT- Let's say I allocate mystring in init and r...

Best practice to pass a value from pop over control on iPad.

It is an iPad app based on SDK 3.2. I have a MainUIView, that is subclass from UIView, it have a UIButton and a UILabel. When user press the UIButton, the pop over control will be appeared with a table view. When the user select a cell from the table view, the UILabel changes content base on the user click, and the pop up table view wil...

Flash of a Bullet in the top left corner of the search results

I am using a UISearchDisplayController and SearchBar initialised from a nib. when the search is being run I get a flash of a small circle what looks like a "bullet" in the top left corner of the search results. [See attached screenshot] It occurs in the simulator and on the device sporadically I have looked through my nib and I am no...

@property setter for BOOL.

Hi, I'm having problems setting a BOOL using @property and @synthesize. I'm using @property BOOL isPaused; And I can get it by using [myObject isPaused]; but I cannot manage to set it. I'd like to use [myObject setPaused: NO];. I also tried @property (setter=setPaused) BOOL isPaused; but if I'm not mistaking, then I need to write that s...

Singleton array deallocated? EXC_BAD_ACCESS

Ok, so I have this singleton object and in it is an array that needs to be shown in a tableview. The thing is that it deallocates and after the first show, i get EXC_BAD_ACCESS in cellForRowAtIndexPath - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[dataBase shareddataBase].dateActive...

Convert charset name to NSStringEncoding

Given a charset string, such as "utf-8", "iso-8859-1", "us-ascii" etc, is there any built-in way to get the appropriate NSStringEncoding in Cocoa? Right now I'm looking at just building a NSDictionary containing a canonicalized version of the name mapped to the NSStringEncoding, then having a lookup mechanism that canonicalizes the inpu...

Comparing against NSLocalizedString safe?

Hi, Sometimes I need to compare interface elements to other objects. At the moment I'm doing it by comparing their titles against a localized string. Am I right that I better compare my objects against IBOutlets? Tags are out of the question because I'm using NSMenu. ...

data not reloading into tableview from core data on minor update

I've got a basic photo album application, on the first view a list of albums is displayed with a subtitle showing how many images are in each album. I've got everything working to add albums, and add images to albums. The problem is that the image count lines are accurate whenever the app loads, but I can't get them to update during exec...

What is the different between an id and NSObject in Objective C?

What is the different between this: id: #import <objc/Object.h> @interface Forwarder : Object { id something; } NSObject: #import <objc/Object.h> @interface Forwarder : Object { NSObject *something; } Thz u. ...

Execute something on application startup?

I have a class in my application which handles all the controls and all the functions and variables are stored in it. How can I add a function which handles the application startup to it? So basically I need to handle 'applicationDidFinishLaunching' in my class as well as in the application delegate. How do I do that? ...

Create NSString from strings within a dictionary

I have an NSDictionary where both the keys and values are NSStrings and I'd like to create one NSString from them in the form of Key1: Value1 Key2: Value2 What is the best method of doing this? ...

Terminating suspended NSTask.

Hi, If I terminate (or interrupt) a suspended NSTask, then it still shows up in activity monitor. It isn't running because the CPU is 0% but it's still taking up memory. Is there a work around? ...

Simplest way to use NSTableView?

Can I use NSTableView like I've used ListView in Windows? By that I mean JUST adding rows to the view. I need to display a very simple two columned table and I don't want to write all this data related crap. Can I just 'add' stuff to a table view? If not what is the simplest way to do what I'm trying to do (preferably without data sour...

Public class: The best way to store and access NSMutableDictionary?

I have a class to help me store persistent data across sessions. The problem is I want to store a running sample of the property list or "plist" file in an NSMutableArray throughout the instance of the Persistance class so I can read and edit the values and write them back when I need to. The problem is, as the methods are publicly defi...

How to build my own library in XCode?

If I created some libraries that I want to give others, but I don't want to share the source code to them (I don't want to give the .h, .m). How can I pack my code to others in XCode? thz. ...

'EXC_BAD_ACCESS' When trying to access a variable?

I get an 'EXC_BAD_ACCESS' error when trying to access variable in a function other than the one it was set in The variable is set in the 'awakeFromNib' function: //Retrieve Session-ID sessionID = [self getSessionID]; And accessed in 'searchBtnClick': NSLog(@"Commening search (%@)",sessionID); // This causes the error The variable ...

Passing arguments by value or by reference in objective C

Hello, I'm kind of new with objective c and I'm trying to pass an argument by reference but is behaving like it were a value. Do you know why this doesn't work? This is the function: - (void) checkRedColorText:(UILabel *)labelToChange { NSComparisonResult startLaterThanEnd = [startDate compare:endDate]; if (startLaterThanEnd ==...

Help with Arrays in Objective C.

Problem : Take an integer as input and print out number equivalents of each number from input. I hacked my thoughts to work in this case but I know it is not an efficient solution. For instance : 110 Should give the following o/p : one one zero Could someone throw light on effective usage of Arrays for this problem? #import <F...

if string is alphabetically greater than other string in objective

I'm trying to use an if statement to work out which of 2 strings comes first alphabetically. Like with numbers and greater and less than: if (1 < 2) { just with strings: if(@"ahello" < @"bhello") { Or would I have to have a string containing all the letters and then check the index of the first char in each string and see which ind...

Getting the Leftmost Bit

I have a 5 bit integer that I'm working with. Is there a native function in Objective-C that will let me know which bit is the leftmost? i.e. I have 01001, it would return 8 or the position. Thanks ...