English 中文(简体)
目标C组永远不会被称作
原标题:Objective-C setter is never called

我试图在多个班子里使国家安全局能够运行。 由于某种原因,我对确定和使用习惯装置有问题,即使我称之为我的主机,也从未执行过(我用这种方法建立了安全记录仪)。 这里是所有相关法典:

<>AppDelegate.h

@interface TouchTrackerAppDelegate : NSObject <UIApplicationDelegate> {

NSMutableArray *completeLines;
}


@property (nonatomic, retain, setter = setCompleteLines:, getter = getCompleteLines) NSMutableArray *completeLines;


-(NSMutableArray*) getCompleteLines;
-(void) setCompleteLines:(NSMutableArray *) newLines;

<>AppDelegate.m

@implementation TouchTrackerAppDelegate

-(NSMutableArray*) getCompleteLines {
return self.completeLines;
}

-(void) setCompleteLines:(NSMutableArray *)newLines {
NSLog(@"gets here");
if (completeLines != newLines) {
    [completeLines release];
    completeLines = [newLines retain];
}

NSLog(@"completeLines global count: %i",[completeLines count]);
}

http://www.ohchr.org。

#import "TouchTrackerAppDelegate.h"

@interface TouchDrawView : UIView {
NSMutableDictionary     *linesInProcess;
NSMutableArray          *completeLines;
TouchTrackerAppDelegate *navigationDelegate;
}
@end

www.un.org/Depts/DGACM/index_french.htm

#import "TouchTrackerAppDelegate.h"

- (id)initWithCoder:(NSCoder *)c 
{
[super initWithCoder:c];
linesInProcess = [[NSMutableDictionary alloc] init];
completeLines = [[NSMutableArray alloc] init];
return self;
}
- (void)viewDidLoad {
navigationDelegate = (TouchTrackerAppDelegate *)[[UIApplication sharedApplication] delegate];
}

-(void)endTouches:(NSSet *)touches
{
if([EditModeSingleton isEditMode]){
for(UITouch *t in touches){
    NSValue *key = [NSValue valueWithPointer:t];
    Line *line = [linesInProcess objectForKey:key];

    if(line){
        [completeLines addObject:line];
        [linesInProcess removeObjectForKey:key];
        [navigationDelegate setCompleteLines:completeLines];
        NSLog(@"completeLines count: %i", [completeLines count]);
    }
}
[self setNeedsDisplay];
}
   else {NSLog(@"in Play mode");}

}

在我所说的话中,问题在于: 就我所知,这从没有执行。 我也不清楚我的定型方法是否正确,我试图从我看来把阵列通过到指定代表供其他类别使用。 如果能更好地做到这一点,我不胜感激。

感谢

最佳回答

If you re not entering that function, there s really only one solid possibility: navigationDelegate is nil. Verify this by logging or asserting it just before sending the message to it in endTouches and then figure out why.

食宿:

    [linesInProcess removeObjectForKey:key];
    [navigationDelegate setCompleteLines:completeLines];

:

    [linesInProcess removeObjectForKey:key];
    NSAssert(navigationDelegate != nil, @"navigationDelegate is nil");
    [navigationDelegate setCompleteLines:completeLines];
问题回答

供今后参考/帮助(并在评论中回答您的问题)——

<>Breakpoint basics in brief:

  • Set breakpoints at or before the line where you suspect your code breaks/fails/behaves-unexpectedly. Run your program in debug...
  • If the breakpoint gets hit: Examine both the call-stack and variable-values in the various Debugging panes in Xcode for clues.
  • Or if the breakpoint is never hit: Go back up a step in your function calls and set a breakpoint there.

否则,点间歇会通过消除进程缩小你的问题,帮助你提出能够更快回答的更好的问题。


虽然StackOverflow帮助你迅速追踪这一问题,但如果你利用破碎点,你可以节省很多时间,将来会感到沮丧。

在此情况下,在以下线上或之前设定一个分点:[navigation Delegate setCompleteLines:completeLines];。 显示<代码>navigationDelegate为零。 然后,你重复:在<代码>navigationDelegate上或之前设定一个断点,并重新启用。 当这一突破点(didn t)被击中时,你就会认识到,你的问题不是你的定点!

你们也许还不得不问“不要把DidLoad称作吗?”,但是,由于你已经解决的部分混乱,你的回答会更快! 今后帮助你的希望





相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签