我的“updateNotes”方法在从“textViewDidEndEditing”调用时有效,但在“handleRightSwipe”(UISwipeGestureRecognizer)中无效。
我在两种方法中使用:
[self performSelector:selector(updateNotes:)];
以下是方法:
- (void)updateNotes: (id)sender
{
Note *noteAtIndex = [self.notes objectAtIndex:countDown];
NSLog(@"noteAtIndex is %@", noteAtIndex);
NSLog(@"noteAtIndex.dayNote is %@", noteAtIndex.dayNote);
//self.noteLabel.text = noteAtIndex.dayNote;
[self.noteTextView setText:noteAtIndex.dayNote];
}
有什么建议吗?
按照建议添加了NSLog:
- (void)updateNotes: (id)sender
{
NSLog(@"self is %@", self);
NSLog(@"self.notes is %@", self.notes);
Note *noteAtIndex = [self.notes objectAtIndex:countDown];
NSLog(@"noteAtIndex is %@", noteAtIndex);
NSLog(@"noteAtIndex.dayNote is %@", noteAtIndex.dayNote);
//self.noteLabel.text = noteAtIndex.dayNote;
NSLog(@"Stack trace : %@",[NSThread callStackSymbols]);
[self.noteTextView setText:noteAtIndex.dayNote];
}
这是日志:
2014-03-03 07:44:07.272 90 Day Track[8194:70b] left swipe detected
2014-03-03 07:44:07.273 90 Day Track[8194:70b] countDown is 1
2014-03-03 07:44:09.760 90 Day Track[8194:70b] notes array is (
"<Note: 0x8e58e40> (entity: Note; id: 0x8e57bc0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p1> ; data: <fault>)",
"<Note: 0x8e59080> (entity: Note; id: 0x8e57bd0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p2> ; data: <fault>)",
"<Note: 0x8e590c0> (entity: Note; id: 0x8e57be0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p3> ; data: <fault>)",
"<Note: 0x8e59100> (entity: Note; id: 0x8e57bf0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p4> ; data: <fault>)",
"<Note: 0x8e59140> (entity: Note; id: 0x8e57c00 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p5> ; data: <fault>)",
"<Note: 0x8e59180> (entity: Note; id: 0x8e57c10 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p6> ; data: <fault>)",
"<Note: 0x8e591c0> (entity: Note; id: 0x8e57c20 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p7> ; data: <fault>)",
"<Note: 0x8e59200> (entity: Note; id: 0x8e57c30 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p8> ; data: <fault>)",
"<Note: 0x8e59240> (entity: Note; id: 0x8e57c40 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p9> ; data: <fault>)",
"<Note: 0x8e59280> (entity: Note; id: 0x8e57c50 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p10> ; data: <fault>)",
"<Note: 0x8e592c0> (entity: Note; id: 0x8e57c60 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p11> ; data: <fault>)",
"<Note: 0x8e59300> (entity: Note; id: 0x8e57c70 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p12> ; data: <fault>)",
"<Note: 0x8e59340> (entity: Note; id: 0x8e57c80 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p13> ; data: <fault>)",
"<Note: 0x8e59380> (entity: Note; id: 0x8e57c90 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p14> ; data: <fault>)",
"<Note: 0x8e593c0> (entity: Note; id: 0x8e57ca0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p15> ; data: <fault>)",
"<Note: 0x8e59400> (entity: Note; id: 0x8e57cb0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p16> ; data: <fault>)",
"<Note: 0x8e59440> (entity: Note; id: 0x8e57cc0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p17> ; data: <fault>)",
"<Note: 0x8e59480> (entity: Note; id: 0x8e57cd0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p18> ; data: <fault>)",
"<Note: 0x8e594c0> (entity: Note; id: 0x8e57ce0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p19> ; data: <fault>)",
"<Note: 0x8e59500> (entity: Note; id: 0x8e57cf0 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p20> ; data: <fault>)",
"<Note: 0x8e59540> (entity: Note; id: 0x8e57d00 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p21> ; data: <fault>)",
"<Note: 0x8e59580> (entity: Note; id: 0x8e57d10 <x-coredata://F27E8E39-7579-4CB5-9637-683892414E95/Note/p22> ; data: <fault>)"
)
2014-03-03 07:44:12.434 90 Day Track[8194:70b] newNote is <Note: 0x8b8a4c0> (entity: Note; id: 0x8b8a4f0 <x-coredata:///Note/tFAB4D984-C9A9-4322-96F4-36AA1557F8E72> ; data: {
day = nil;
dayNote = Notes;
})
2014-03-03 07:44:12.435 90 Day Track[8194:70b] newDay is <Day: 0x8b8fbe0> (entity: Day; id: 0x8b8e7f0 <x-coredata:///Day/tFAB4D984-C9A9-4322-96F4-36AA1557F8E73> ; data: {
dayNumber = 1;
note = nil;
})
2014-03-03 07:44:15.860 90 Day Track[8194:70b] right swipe detected
2014-03-03 07:44:15.861 90 Day Track[8194:70b] countDown is 2
(lldb)
答案 0 :(得分:1)
performSelector:
仅适用于不带参数的方法。 performSelector:withObject:
使用一个参数的方法,这就是你拥有的(updateNotes:
)。
(另外,为什么你使用带有固定选择器的performSelector...
?为什么不直接拨打电话?)