I have the following designated initializer:
-(id) initWithName:(NSString*)name;
and the following default initializer:
-(id) init { return [self initWithName:@"foo"]; }
What kind of object does the designated initializer receive than? A released or a autoreleased?
given the following initializer:
-(id) init { return [self initWi...
Hello guys,
I'm trying to use dateFromString method from NSDateFormatter but it somehow doesn't work for me. I made a test case to show my problem:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:MM"];
NSString *kkk = @"Thu, 15 Oct 2009 10:00";
NSString *t...
Hi Everyone,
I have three view controllers, one root controller, one login view controller and one customers view controller. I want to pass the entered username and password in login view controller to the customers view controller. My files and code is displayed below, could you please guide me, how can access to variables set in the ...
NSDictionary *topic = [spaces objectAtIndex:i];
NSInteger topicid = [topic valueForKey:@"TOPICID"];
when I run this and print out topic I get the following:
Printing description of topic:
<CFDictionary 0xdb2a70 [0x30307a00]>{type = mutable, count = 2, capacity = 12, pairs = (
10 : <CFString 0xdb5300 [0x30307a00]>{contents = "TOP...
For example I have a game with a menu screen and then I have the game itself. I want the timer disabled whilst playing the game but enabled when in the menu screen. I currently have the following code in my app delegate that disables the timer:
application.idleTimerDisabled = YES;
Any help would be appreciated.
...
I'm a new iPhone/Objective-C developer and as I'm going through different tutorials and open source code, I am having a bit of a problem understanding when to use the square brackets "[ ]" and when to use the period " . " for accessing properties/methods of an object.
For example, this code:
- (void)setSelected:(BOOL)selected animated:...
I'm aware that it's perfectly fine to send messages to nil objects in Objective-C. However, I am curious if there is any runtime support for flagging such situations. I can see this being useful in testing/debugging situations.
...
I am unable to populate the previewData NSMutableArray with this code. XML request is successfully retrieved, parsed but I am unable to populate the previewData array for tableviewController.
PreviewsController.h code:
#import <UIKit/UIKit.h>
@interface PreviewsController : UIViewController
<UITableViewDelegate, UITableViewDataSo...
Don't shoot me, I know this must have been asked a thousand times...
I am not comfortable with the lack of good documentation on Objective-C memory. I understand alloc, dealloc, retain, release and all that but there is some confusion left in my head.
Is it just lazy programming or does Objective-C do some 'behind the scenes' automagi...
I have an app, using Core Data with a SQLite store.
At some point I'd like to remove all objects for a few entities. There may be close to a thousand objects.
From what I can tell via google and the official docs, the only way to delete objects is to [managedObjectContext deleteObject:(Entity *)] for every object. But this means that I...
Is there any functional programming library for Objective-C?
...
I am very new to iPhone Development so pardon me if this is a novice question. I have an app with a RootController that controls loading the various views. It initially loads a MenuView. The MenuView has a button that when a user clicks I want to open a whole different view (called InfoView) that displays some information about the ap...
As is common knowledge, calls to alloc/copy/retain in Objective-C imply ownership and need to be balanced by a call to autorelease/release. How do you succinctly describe where this should happen? The word "succinct" is key. I can usually use intuition to guide me, but would like an explicit principle in case intuition fails and that can...
Hello Everyone!
Can anyone help me make a EDMessage Sample Code? I don't know how to set up my headers and what the proper coding to input into my application. Here's the link if you need resources. BTW EDMessage is a framework used to send emails. EDMESSAGE. Here is the code I have so far for my headers:
#import <Cocoa/Cocoa.h>
@int...
Hi.
The simplest code ever in Objective-C causes weird behavior:
#import Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSObject *obj = [[NSObject alloc] init];
NSLog(@"retain count %d",[obj retainCount]);//print 1
[obj release];//obj dea...
I am trying to solve a problem in Objective-C, but I don't think the question is language specific.
I have to do some processing down in a model class that has no notion of UI. However, this processing takes some time and I want to let the user know the status via a progress bar.
My first attempt at this was defining a notion of a pr...
I'm not really familiar with the connection protocols.
I'm using the following code to examine connect() so I can get the hostname:
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
int error;
char hostname[NI_MAXHOST] = "";
error = getnameinfo(serv_addr, addrlen, hostname, NI_MAXHOST, NULL, 0, 0);
if (error !=0) {
ALogTC...
I have set up a Core Data model where I have two objects, say Person and Address. A person has an address, and an address can belong to many people. I have modelled it in core data as such (so the double arrow points to Person, while the single arrow goes to Address)
I have then created two classes for those objects, and implemented som...
This is probably a naive question but, how do I get the length of the stringValue of an NSTextField? I tried
int len = strlen((char *)[textField stringValue]);
where textField is an NSTextField but it always returns 6 (size of a pointer?). Besides I am sure that there is a more Objective-C way to do what I am after.
...
Is it acceptable for a instance method of a class to release itself?
ie to have a method that calls:
[self release]
Assume that my code is not going to access self after calling [self release]
...