How to run JUnit tests by category in Maven?

Maven has since been updated and can use categories. An example from the Surefire documentation: <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.11</version> <configuration> <groups>com.mycompany.SlowTests</groups> </configuration> </plugin> This will run any class with the annotation @Category(com.mycompany.SlowTests.class)

Overriding methods using categories in Objective-C

From Apple documentation: Although the Objective-C language currently allows you to use a category to override methods the class inherits, or even methods declared in the class interface, you are strongly discouraged from doing so. A category is not a substitute for a subclass. There are several significant shortcomings to using a category to override … Read more

Can a category implement a protocol in Objective C?

Yes, that’s possible. The syntax is: @interface NSDate (CategoryName) <ProtocolName> @end @implementation NSDate (CategoryName) @end Here’s Apple’s documentation on the topic. It’s also possible to do this using a class extension. I very much like this to privately conform to delegate protocols. Doing so hides the implementation detail of being some delegate of some class … Read more

Objective-C: Property / instance variable in category

.h-file @interface NSObject (LaserUnicorn) @property (nonatomic, strong) LaserUnicorn *laserUnicorn; @end .m-file #import <objc/runtime.h> static void * LaserUnicornPropertyKey = &LaserUnicornPropertyKey; @implementation NSObject (LaserUnicorn) – (LaserUnicorn *)laserUnicorn { return objc_getAssociatedObject(self, LaserUnicornPropertyKey); } – (void)setLaserUnicorn:(LaserUnicorn *)unicorn { objc_setAssociatedObject(self, LaserUnicornPropertyKey, unicorn, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } @end Just like a normal property – accessible with dot-notation NSObject *myObject = [NSObject new]; myObject.laserUnicorn … Read more

Objective-C categories in static library

Solution: As of Xcode 4.2, you only need to go to the application that is linking against the library (not the library itself) and click the project in the Project Navigator, click your app’s target, then build settings, then search for “Other Linker Flags”, click the + button, and add ‘-ObjC’. ‘-all_load’ and ‘-force_load’ are … Read more

How to get rid of the ‘undeclared selector’ warning

Another option would be to disable the warning with: #pragma GCC diagnostic ignored “-Wundeclared-selector” You can place this line in the .m file where the warning occurs. Update: It works also with LLVM like this: #pragma clang diagnostic push #pragma clang diagnostic ignored “-Wundeclared-selector” … your code here … #pragma clang diagnostic pop

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)