selector

Why is objc_msgSend causing an EXC_BAD_ACCESS?

瘦欲@ 提交于 2019-12-10 13:28:35
问题 I'm making a class, that given an object target, a selector to watch for, and a displayTitle will output a string in this format: @"displayTitle: object.selector" . It then registers itself through KVO so that anytime the value of object.selector changes, it can notify a view controller to update the view. I am using this as an abstract and reusable way to show a description of various properties of an object to a user. When I try to get the value of object.selector , I can't do [object

jQuery get <td> text from <tr> id, <td> is dynamically generated so I don't know how may or if any

你。 提交于 2019-12-10 13:09:48
问题 I have a jQuery function already to perform the task I need but is there a way to loop through the <td> cells of a specific <tr> with the id="generated_rows" <table> <tr id="generated_rows"> <td class="row_class" id="row_id_1">text 1</td> <td class="row_class" id="row_id_2">text 2</td> <td class="row_class" id="row_id_3">text 3</td> <td class="row_class" id="row_id_4">text 4</td> <td class="row_class" id="row_id_5">text 5</td> </tr> </table> Need this: <table> <tr id="generated_rows"> <td

Problem with NSSortDescriptor using custom comparator via selector

主宰稳场 提交于 2019-12-10 12:45:34
问题 I want to use a sortdescriptor with a custom comparator NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"object.dateTime" ascending:YES selector:@selector(compareObject:toObject:)]; (the key is a ManagedObject) Comparator method: - (NSComparisonResult)compareObject:(id)date1 toObject:(id)date2 { NSComparisonResult comparisonResult; // Complex comparator contents return comparisonResult; } However, I get an error: 'NSInvalidArgumentException ', reason: '-[__NSDate

Need/want to pass an NSError** as an argument to performSelector

一笑奈何 提交于 2019-12-10 10:26:59
问题 I want to invoke a selector of a method that has the usual NSError** argument: -(int) getItemsSince:(NSDate *)when dataSelector:(SEL)getDataSelector error:(NSError**)outError { NSArray *data = nil; if([service respondsToSelector:getDataSelector]) { data = [service performSelector:getDataSelector withObject:when withObject:outError]; // etc. ... which the compiler doesn't like: warning: passing argument 3 of 'performSelector:withObject:withObject:' from incompatible pointer type Is there any

Trouble passing Swift 4 String to Obj-C++ -[_SwiftValue dataUsingEncoding:]: unrecognized selector sent to instance

ぐ巨炮叔叔 提交于 2019-12-10 10:16:28
问题 I have some Objective-C++ code like this: // header @interface MyObjcClass - (void) myMethod: (NSString *) text; @end // implementation @implementation MyObjcClass - (void) myMethod: (NSString *) text { someInternalObject->useWstring(nsStringToWstring(text)) } std::wstring nsStringToWstring(const NSString * text) { NSData * data = [text dataUsingEncoding: NSUTF32LittleEndianStringEncoding]; // and then some other stuff irrelevant to this question return std::wstring(pointerToNewString,

jQuery caching selectors

自古美人都是妖i 提交于 2019-12-10 09:33:04
问题 I have div with id #wrapper and all element are inside it. I'm caching wrapper by doing var $wrapper = $('#wrapper'); Now any time i want to make a selector or reference an element, i do $wrapper.find('#whatever').click(.... By doing this i avoid wrapping with jQuery object again, so any selector i do in the future will be based on the cached $wrapper . But on the other when i use find() with the cached $wrapper, i know it will search all elements inside #wrapper . My questions is whic is

jQuery/JavaScript: selecting first “layer” of children only

北城余情 提交于 2019-12-10 09:08:06
问题 I'm trying to select only the first "layer" of children elements of a given type, but not elements nested inside another qualifying element. E.g. in: <div id='top'> <div id="s1" class="special"> <div id="s2" class="special"></div> </div> <div> <div id="s3" class="special"></div> </div> </div> I'd like to find #s1 and #s3, but not #s2, with something like $('#top').find('.special:not_nested'). Is it possible with jQuery? XPATH? I thought about jQuery custom filters like expr[':'].not_nested,

jQuery find all id's that begin with a defined string and end in a number

旧巷老猫 提交于 2019-12-10 07:06:16
问题 I would like to do something like this: jqueryElement.find('divIdWithIterator**').each(...); where 'divIdWithIterator**' matches all elements with ids that start with 'divIdWithIterator' and end in a number, such as: divIdWithIterator1, divIdWithIterator2, divIdWithIterator26 What is a good way to do this in jQuery? Thanks! 回答1: Unfortunately, there is no regular expression selector. You could use the attribute-starts-with selector, then filter the results and check for numeric endings using

iOS开发之 [NSNull length]:unrecognized selector sent

不羁岁月 提交于 2019-12-10 03:08:36
错误 [NSNull length]:unrecognized selector sent to instance 这个错误是从字典中取出值后,没有判断取出的字符串是否为空,就对字符串进行测长度的 操作. 正确做法是取出字符串后,先进行判断是否为空,再测长度或其他操作 判断是否为空的方法要选正确 开始走入了一个误区,一直用if(runTitle == nil)和[runTitle isEqualsString@""]等一些判断是否为空,结果都报错。 后来使用[runtitle isKindOfClass:[NSNull class]]来判断解决了这个问题。 来源: oschina 链接: https://my.oschina.net/u/2361492/blog/651238

NSOpenPanel get filename in Objective-C?

。_饼干妹妹 提交于 2019-12-09 23:33:51
问题 When I create an NSOpenPanel, like this: int i; NSOpenPanel* openDlg = [NSOpenPanel openPanel]; [openDlg setCanChooseFiles:YES]; [openDlg setCanChooseDirectories:YES]; if ([openDlg runModalForDirectory:nil file:nil] == NSOKButton) { NSArray* files = [openDlg filenames]; for( i = 0; i < [files count]; i++ ) { NSString* fileName = [files objectAtIndex:i]; NSLog(fileName); NSString *catched = fileName; [self performSelector:@selector(decompresss2z:) withObject:catched]; } } And when I log