objective-c

Objective-C: NSLog prints (null) for a var assigned to nil?

I'm curious why a variable overtly assigned to nil, prints as (null) with NSLog: NSString *myVar = nil; NSLog(@"%@", myVar); # RESULT: ' (null) ' This is of course quite confusing given all the different kinds of "nothingness" to figure out in Objective-C, and had me trying to test various IF NULL syntaxes. ...

Unexpected results when returning long long in a method call

I've encountered a strange occurrence when I pass a long long value back from a method call. In my app I've already worked around this but I am curious to know why this is. Can someone explain to me, when I have a method as defined: - (long long)testLong { NSString* longString = @"100000133597162"; long long retval = [longStrin...

how to get event/Occassion name from date picker?

I want to know that it is possible to get event name from datepicker like if i select 25 december and get christmas as event name etc. ...

Authenticate on a website and Screen scraping with objective-c

I'm developing an iPhone application where I wish to authenticate (login form) on a site and retrieve some information by doing some screen scraping. Is there an API available to do this or documentation how I could do this? thanks ...

NSZombieEnabled does not work

When I set NSZombieEnabled = Yes nothing is written to the console. How can I fix this? Or can you advise me any other tools for an EXC_BAD_ACCESS? ...

Encrypt and Decrypt password using objective-c

Hi, How to encrypt a nsstring and store it in a file, and how to decrypt the same. Please suggest me wat api's i shld use... ...

Need help: My program should react when an other class is doing something specific - Not as easy as it sounds

Hello, I´m writing an program that uses twitter. I want that my app shows an UIAlertView when the user presses on the "Tweet"-Button and the username or password is wrong. For my Twitterfunction I use the TwitterRequest.m/h from Brandon Trebitowski. If everthing works great and the username/password is right, this happens in my app: ...

copyWithZone setting instance variables?

Is the copyWithZone (See Below) correct, particularly the bit where I use the setters to populate the instance variables of the new object? @interface Planet : NSObject <NSCopying> { NSString *name; NSString *type; NSNumber *mass; int index; } @property(copy) NSString *name; @property(copy) NSString *type; @property(reta...

iphone code - custom table instead of default one

hi, i'm using a default style table (UITableViewCellStyleSubtitle) i want to add more then one detailTextLabel in each row, how can i customize it? code: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubt...

iPhone Application in spanish using foreign characters

Hi guys. i'm making an iphone application using some characters of spanish language. All of these characters are being included on a various text files. The matter is that when i import the data using NSMutableArrays or NSData objects, all the special characters was replaced for extranges symbols. I try to solve this problem using for al...

Memory Management in Objective-c

If retainCount return An unsigned int, how come [@"Hi" retainCount] returns -1 ...

How to sort model object by object in dictionary?

Hi, I've a model object that extends from NSObject called column. Column has two fields, properties and data. Properties is an NSDictionary that stores arbitrary key/value pairs while data is an array. Columns come in arrays and I need to sort them by a value I know will always be in properties, a value with the key ordinal_position. ...

OCMock on a method with argument and returns a value

I have a class that relies on NSUserDefaults that I'm trying to unit-test and I'm providing the NSUserDefaults as a mock into my test class. When running the test, I get the error: OCMockObject[NSUserDefaults]: unexpected method invoked: dictionaryForKey:@"response" I'm trying to mock this instance method of the NSUserDefaults ...

Category before class.

Just want to check: If you have a class that uses a method added to an existing objective-c object (i.e. NSArray) that you must define the category before the class that uses the category method. By accident I had done this the wrong way round and got the rather cryptic error ... warning: cannot pass object of non-POD type 'void' throu...

NSAssert usage in threads

I'm trying to use NSAssert throughout my iPhone app so that if an unexpected condition occurs, the application fails-fast and crashes with a meaningful message in the crash log. This works fine if the failing NSAssert is on the main thread, as it raises NSInternalInconsistencyException by default which is uncaught and stops execution. B...

mutableCopyWithZone, copy NSMutableArray?

I a trying to make a mutableCopy of a planet object that contains 5 instance variables (one of them being an NSMutableArray of string literals. My problem is that I am unsure how to set the newPlanet>data to a copy of self>data, does that make sense? -(id) mutableCopyWithZone: (NSZone *) zone { Planet *newPlanet = [[Planet allocWith...

Custom UITableViewCell rounded corners (grouped style)

When creating a custom UITableViewCell I notice that it looks as expected in 'plain' style but that the corners of the cells are not rounded if the table view is displayed in 'grouped' style: i.e. the corners are square. I have searched but cannot find any real explanation of why this happens and, more importantly, how to remedy this ef...

How to make Action Sheet button open new view

I have an iPhone app that uses an action sheet but I can't work out how to make one of the buttons open a new view when pressed. I know how to implement the action sheet - that's not a problem, its the actual action of opening the new view that's the issue. Any help would be greatly appreciated. Thanks. ...

How should I handle a failure in an init: method in Objective-C?

Let's say I'm building a new class for the iPhone in Objective-C. In one of my init methods I want to manually allocate some memory. So, I might have something like this: - (id)initWithSomeObject:(SomeObject *)someObject { self = [super init]; if (self != nil) { myObject = someObject; [myObject retain]; if ( (memory = ...

Behaviour of a searchDisplayController.searchResultsTableView inside a UINavigationController logic

I have a ordinary UITableViewController inside a UINavigationController. The former includes a searchbar which is connected to a search display controller. I use the standard behaviour, i.e. when the user enters any character the search results table view overlays the normal table view. Now, both table views act inside a navigation cont...