Posts

ios - How do I access the dealloc method in a class category? -

ios - How do I access the dealloc method in a class category? - i need perform action in dealloc method of category. i've tried swizzling doesn't work (nor great idea). in case asks, reply no, can't utilize subclass, category. i want perform action on delay using [nstimer scheduledtimerwithtimeinterval:target:selector:userinfo:repeats:] or [self performselector:withobject:afterdelay:] , cancel on dealloc. the first issue nstimer retains target, don't want. [self performselector:withobject:afterdelay:] doesn't retain, need able phone call [nsobject cancelpreviousperformrequestswithtarget:selector:object:] in dealloc method or crash. any suggestions how on category? i stumbled on solution haven't seen before, , seems work... i have category that--as 1 does--needs state variables, utilize objc_setassociatedobject , this: memento *m = [[[memento alloc] init] autorelease]; objc_setassociatedobject(self, kmementotagkey, m, objc_assoc...

c++ - is this code safe? cast a std::vector to std::vector -

c++ - is this code safe? cast a std::vector<Derived*> to std::vector<Base*> - basically i've class a , class b : public a . and i'd cast std::shared_ptr<std::vector<a*> std::shared_ptr<std::vector<b*> the problem std::vector<b> doesn't inherit std::vector<a> , , smart_ptr neither. horrible cast: std::shared_ptr<vectora> vector_a = * ((std::shared_ptr<vectora>*)&vector_b); the code compiles , runs there, safe? http://liveworkspace.org/code/3dqtz1$0 strictly speaking dereferencing operations should succeed. both vectors pointer containers, casting 1 another, whilst unacceptable production code, still utilize same dimensions , alignment. c++ provides rich abstractions avoid these shenanigans though, improve populate vector of derived objects pointers base of operations class. c++ inheritance casting

mysql - I want to find the person with the 22nd highest salary -

mysql - I want to find the person with the 22nd highest salary - i using mysql, have 50 records in employee table. want find person 22nd highest salary. use limit , specifying both offset , row count. to 22nd ranked person in order of highest salary, do: select person employee order salary desc limit 21, 1 notice utilize of 21 here. because offset of initial row (1st highest salary) 0. hence 22nd highest salary offset of 21 (the 21st row in 0-based counting, or "skip 21 rows"). to person(s) 22nd highest salary, need 1 more level of indirection. try: select person employee salary = ( select distinct salary employee order salary desc limit 21, 1 ) mysql

c# - Prevent graceless crash from occurring in application calling library via P/Invoke -

c# - Prevent graceless crash from occurring in application calling library via P/Invoke - i have c# application app a calls, via p/invoke, c++ (qt) dll app b . let's assume cannot, means, edit app b , know app b throwing out of memory exception under set of conditions can replicate not accurately test before passing input app a app b . exception not pose threat app a , ignored if app b "reset" in manner, when app b crashes calls abort() in turn causes app a 's runtime terminate. how can prevent app b 's inevitable, unpredictable, , mundane crash impacting app a ? notes: an implemented unhandledexceptionhandler ignored when error thrown. app b crashes due bug in qtwebkit feasibly handled app b via deleting oversize object , returning null. app a not study out of memory , machine has more plenty memory perform app b 's operation several times over, regardless of bug, memory apparently not allocated app b whatever reason. you can...

Android, java, Xml Parsin Using Dom -

Android, java, Xml Parsin Using Dom - how can parse tag using dom? <gd:where starttime="jan 4 2012" endtime="jan 5 2012"/> i wants starttime , endtime tag. try using this getattributevalue(null,"starttime") java android xml xml-parsing

c++ - What happens if compiler inlines a function which is called through a function pointer -

c++ - What happens if compiler inlines a function which is called through a function pointer - let have function in programme , somewhere in code, function called through function pointer. happens if compiler happened inline function, or compiler realize there function pointer assigned function , hence avoid inlining it. when pointer function taken, compiler generate out-of-line body function. still possible inline function @ other phone call sites. note function marked inline must have definition available in tus refer it, , these definitions must identical. means it's safe inline function @ phone call sites , maintain out-of-line @ others. c++ c compiler-construction

c++ - How does linker deal with virtual functions defined in multiple headers? -

c++ - How does linker deal with virtual functions defined in multiple headers? - suppose have base.h class base of operations { virtual void foo() {...} }; derived1.h class derived1 : public base of operations { virtual void foo() {...} }; derived2.h class derived2 : public base of operations { virtual void foo() {...} }; header derived1.h included in multiple source files , derived1 class used through base interface. since foo virtual , used polymorphic can not inlined. compiled in multiple obj files. how linker resolve situation? member functions defined within class definition implicitly inline (c++03 7.1.2.3). whether function body gets inlined @ point of calling immaterial. inline allows have multiple definitions of function long definitions same(which disallowed 1 definition rule)(c++03 7.1.2.2). standard mandates linker should able link (one or)many of these definitions.(c++03 7.1.2.4). how linker this? the standard ...