Skip to main content

Posts

Showing posts from March 9, 2012

Scanner vs. StringTokenizer vs. String.Split

I just learned about Java's Scanner class and now I'm wondering how it compares/competes with the StringTokenizer and String.Split. I know that the StringTokenizer and String.Split only work on Strings, so why would I want to use the Scanner for a String? Is Scanner just intended to be one-stop-shopping for spliting?

How to convert Milliseconds to "X mins, x seconds” in Java?

I want to record the time using System.currentTimeMillis() when a user begins something in my program. When he finishes, I will subtract the current System.currentTimeMillis() from the start variable, and I want to show them the time elapsed using a human readable format such as "XX hours, XX mins, XX seconds" or even "XX mins, XX seconds" because its not likely to take someone an hour. What's the best way to do this?

Are Java static initializers thread safe?

I'm using a static code block to initialize some controllers in a regsitry I have. My question is therefore, can I guarantee that this static code block will only absolutely be called once when the class is first loaded? I understand I cannot guarantee when this code block will be called, Im guessing its when the Classloader first loads it. I realize I could synchronize on the class in the static code block, but my guess is this is actually what happens anyway? Simple code example would be; class FooRegistry { static { //this code must only ever be called once addController(new FooControllerImpl()); } private static void addController(IFooController controller) { // ... } } or should I do this; class FooRegistry { static { synchronized(FooRegistry.class) { addController(new FooControllerImpl()); } } private static void addController(IFooController controller) { // ... } }

How to send java.util.logging to log4j?

I have an existing application which does all of its logging against log4j. We use a number of other libraries that either also use log4j, or log against Commons Logging, which ends up using log4j under the covers in our environment. One of our dependencies even logs against slf4j, which also works fine since it eventually delegates to log4j as well. Now, I'd like to add ehcache to this application for some caching needs. Previous versions of ehcache used commons-logging, which would have worked perfectly in this scenario, but as of version 1.6-beta1 they have removed the dependency on commons-logging and replaced it with java.util.logging instead. Not really being familiar with the built-in JDK logging available with java.util.logging, is there an easy way to have any log messages sent to JUL logged against log4j, so I can use my existing configuration and set up for any logging coming from ehcache? Looking at the javadocs for JUL, it looks like I could set up a bunch of

Why C# implements methods as non-virtual by default?

Unlike Java, why C# treats methods as non-virtual functions by default? Is it more likely to be a performance issue rather than other possible outcomes? I remind reading a paragraph from Anders Hejlsberg about the several advantages the existing architecture is bringing out. But, what about side effects? Is it really a good trade-off to have non-virtual methods by default?

Why is Spring"s ApplicationContext.getBean considered bad?

I asked a general Spring question and had multiple people respond that calling Spring's ApplicationContext.getBean() should be avoided as much as possible. Why is that? How else should I gain access to the beans I configured Spring to create? I'm using Spring in a non-web application and had planned on accessing a shared ApplicationContext object as described by LiorH . Amendment I accept the answer below, but here's an alternate take by Martin Fowler who discusses the merits of Dependency Injection vs. using a Service Locator (which is essentially the same as calling a wrapped ApplicationContext.getBean() ). In part, Fowler states, " With service locator the application class asks for it [the service] explicitly by a message to the locator. With injection there is no explicit request, the service appears in the application class - hence the inversion of control. Inversion of control is a common feature of frameworks, but it's something that comes

GWT Custom Event Handler

Can someone give me an example of creating a custom set of an Event and a Handler. Say you have a Person object that you want your widgets to know if it got updated. You create a HandlerManager and now you have to create an Event and a Handler. How would you define those classes so that you can subscribe and fire events? Most of the Events are DOM based, while I want to create some custom events and handlers that I can fire outside of any browser-based event.

Https Connection Android

I am doing a https post and I'm getting an exception of ssl exception Not trusted server certificate. If i do normal http it is working perfectly fine. Do I have to accept the server certificate somehow?

Modifying final fields in Java

Let's start with a simple test case: import java.lang.reflect.Field; public class Test { private final int primitiveInt = 42; private final Integer wrappedInt = 42; private final String stringValue = "42"; public int getPrimitiveInt() { return this.primitiveInt; } public int getWrappedInt() { return this.wrappedInt; } public String getStringValue() { return this.stringValue; } public void changeField(String name, Object value) throws IllegalAccessException, NoSuchFieldException { Field field = Test.class.getDeclaredField(name); field.setAccessible(true); field.set(this, value); System.out.println("reflection: " + name + " = " + field.get(this)); } public static void main(String[] args) throws IllegalAccessException, NoSuchFieldException { Test test = new Test(); test.changeField("primitiveInt", 84); System.out.println("direct: primitiveInt = " + test.getPrimitiveInt()); test.

Is it good practice to use java.lang.String.intern()?

The Javadoc about String.intern() doesn't give much detail. (In a nutshell: It returns a canonical representation of the string, allowing interned strings to be compared using == ) When would I use this function in favor to String.equals() ? Are there side effects not mentioned in the Javadoc, i.e. more or less optimization by the JIT compiler? Are there further uses of String.intern() ?

Find Oracle JDBC driver in Maven repository

I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14. In MVNrepository site the dependency to put in the POM is: <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc14</artifactId> <version>10.2.0.3.0</version> </dependency> of course this does't work as it is not in the central repository used by maven. 2 questions: How do I find a repository (if any) that contains this artifact? How do I add it so that Maven will use it?

Are there some good and modern alternatives to Javadoc?

Let's face it: You don't need to be a designer to see that default Javadoc looks ugly . There are some resources on the web which offer re-styled Javadoc. But the default behaviour represents the product and should be as reasonably good-looking. Another problem is the fact that the usability of Javadoc is not up-to-date compared to other similar resources. Especially huge projects are hard to navigate using Firefox's quick search. Practical question: Are there any standalone (desktop) applications which are able to browse existing Javadoc in a more usable way than a browser would? I'm thinking about something like Mono's documentation browser. Theoretical question: Does anyone know, if there some plans to evolve Javadoc, in a somehow-standardized way? EDIT: A useful link to Sun' wiki on this topic .

Is Catching a Null Pointer Exception a Code Smell?

Recently a co-worker of mine wrote in some code to catch a null pointer exception around an entire method, and return a single result. I pointed out how there could've been any number of reasons for the null pointer, so we changed it to a defensive check for the one result. However, catching NullPointerException just seemed wrong to me. In my mind, Null pointer exceptions are the result of bad code and not to be an expected exception in the system. Are there any cases where it makes sense to catch a null pointer exception?

Permission to write to the SD card

I would like my app to archive the application DB to the SD card. In my code I check if the directory canWrite(), and if not then throw an IOException. In this perticular instance, I am trying to copy the db file to the root directory on the SD card, but its throwing an IOException. How can I change the permission on a folder/file to be able to write to it? thanks patrick

Google Guice vs. PicoContainer for Dependency Injection

My team is researching dependency injection frameworks and is trying to decide between using Google-Guice and PicoContainer. We are looking for several things in our framework: A small code footprint - What I mean by a small code footprint is we don't want to have dependency injection code litter everywhere in our code base. If we need to refactor down the road, we want it to be as easy as possible. Performance - How much overhead does each framework have when creating and injecting objects? Ease of use - Is there a large learning curve? Do we have to write mounds of code to get something simple working? We want to have as little configuration as possible. Community size - Larger communities usually means that a project will continue to be maintained. We don't want to use a framework and have to fix our own bugs ;) Also any questions we have along the way can (hopefully) be answered by the framework's developer/user community . Comparisons of the two f

Loaders in Android Honeycomb

I'm trying to figure out how to use Loaders in Android 3.0 but can't seem to get it to work. The docs only describe using CursorLoader but I'm using AsyncTaskLoader. From the docs it seems that you should only need to implement AsyncTaskLoader.loadInBackground() but it never gets called after getLoaderManager().initLoader() and then creating the loader in the callback. I can see debug messages saying Created new loader LoaderInfo{4040a828 #0 : ArticleDataLoader{4036b350}} so it seems like it is created successfully. Is it possible that loaders are currently broken in the SDK or is there some method you need to call after creating the loader? (they don't do that in the CursorLoader example). EDIT: Seems like calling forceLoad() on the Loader returned from initLoader() starts the loading at least but this means you can't handle rotations correctly :(

Is volatile expensive?

After reading http://gee.cs.oswego.edu/dl/jmm/cookbook.html about the implementation of volatile, especially section "Interactions with Atomic Instructions" I assume that reading a volatile variable without updating it needs a LoadLoad or a LoadStore barrier. Further down the page I see that LoadLoad and LoadStore are effectively no-ops on X86 CPUs. Does this mean that volatile read operations can be done without a explicit cache invalidation on x86, and is as fast a normal variable read (disregarding the reordering constraints of volatile)? I believe I don't understand this correctly. Could someone care to enlighten me? EDIT: I wonder if there are differences in multi-processor environments. On single CPU systems the CPU might look at it's own thread caches, as John V. states, but on multi CPU systems there must be some config option to the CPUs that this is not enough and main memory has to be hit, making volatile slower on multi cpu systems, right? PS: On

Monotouch or Titanium for rapid application development on IPhone?

As a .Net developer I always dreamed for the possibility to develop with my existing skills (c#) applications for the Iphone. Both programs require a Mac and the Iphone Sdk installed. Appcelerator Titanium was the first app I tried and it is based on exposing some Iphone native api to javascript so that they can be called using that language. Monotouch starts at $399 for beeing able to deploy on the Iphone and not on the Iphone simulator while Titanium is free. Monotouch (Monodevelop) has an Ide that is currently missing in Titanium (but you can use any editor like Textmate, Aptana...) I think both program generate at the end a native precompiled app (also if I am not sure about the size of the final app on the Iphone as I think the .Net framework calls are prelilnked at compilation time in Monotouch). I am also not sure about the full coverage of all the Iphone api and features. Titanium has also the advantage to enable Android app development but as a c# developer I s

NSLog with CGPoint data

I have a CGPoint called point that is being assigned a touch: UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; I want to get the x coordinate value into my console log: NSLog(@"x: %s", point.x); When I use this, log output for this is: x: (null) I have verified that point is not null when this is called using the debugger and variable watch. Any help appreciated, Thanks // :)

Setting an image for a UIButton in code

How do you set the image for a UIButton in code? I have this: UIButton *btnTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btnTwo.frame = CGRectMake(40, 140, 240, 30); [btnTwo setTitle:@"vc2:v1" forState:UIControlStateNormal]; [btnTwo addTarget:self action:@selector(goToOne) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btnTwo]; but don't see what will set the image for it. Any help appreciated, Thanks // :)

How to set the Navigation Bar Color of the Tab Bar Configure Menu

As you can see the view I need to change is the provided view to customize the tabbar order. I want to change the color of the navigation bar (displaying "Konfigurieren" which means "Configure"), I already found out how to change the color of the "More"-Navigation Controller, but not this one. Can anybody help me with that?

Cocos2d adding a background image to a layer?

I just finished reading some of the cocos2d documentation, and as far as I understand to add a background image to a layer you have to do something like: Sprite * bg = [Sprite spriteWithFile:@"Background.png"]; [layer addChild:bg z:0]; Allthough as far as my testing goes you can just directly add the sprite to the scene like this: @implementation IntroScene - (id) init { self = [super init]; if (self != nil) { Sprite * bg = [Sprite spriteWithFile:@"Background.png"]; [bg setPosition:ccp(240, 160)]; [self addChild:bg z:0]; [self addChild:[MenuLayer node] z:1]; } return self; } What is the difference between this 2 options, and what is the better way to set a background for a layer?. Any help will be greatly appreciated.

Minimum sensible button size on iPhone

I'm designing an iPhone app that features a rather large set of onscreen rounded rect buttons. Given finger-based touchscreen UI, what do you think would be the smallest sensible button size? I need to fit as many of them as I can in the viewport without compromising the usability too much. Maybe there's an Apple-recommended minimum size? Right now it's 33x33, and it looked OK on a simulator, but I was playing with the app on a real phone last night, and it was awkward - the buttons felt too small.

When to use restoreCompletedTransactions for in-app purchases?

For a basic app with nonconsumable in-app purchases, has anyone figured out best practices for using SKPaymentQueue's restoreCompletedTransactions ? Observations I know it's recommended to always register a transaction observer to receive pending transactions that make their way back to the app, but this is a different question. It looks like restoreCompletedTransactions is something the app has to actively decide when to call to poll for all the purchases the customer has already made. From what I can tell, the method is designed to retrieve purchases that may have been lost. For example a customer might install or move an app to a new device in such a way where the user defaults (where Apple recommends recording nonconsumable payments) are lost or reset. Concerns What's not clear to me is how to automatically detect this condition (i.e. how to decide when to poll for missing purchases) in a reliable way. I don't want to screw this up and risk denying a c

What is the state of non-Objective-C programming for iPhone?

After spending three weeks learning Objective-C and Cocoa programming for my work, I've been tasked with researching alternatives to it for iPhone development. I know of two existing alternatives, and one future possibility. C# MonoTouch is a C#.NET implementation with bindings for iPhone specific functionality such as touch screen and accelerometer. It integrates with Xcode and Interface Builder and also allows for custom Objective-C bindings to be made. Java alcheMo-for-iPhone generates C++ code to be compiled for iPhone from J2ME source. It also provides touch screen and accelerometer bindings. Flash / ActionScript 3 Adobe has announced that Flash Professional CS5 will allow Flash applications to be deployed for iPhone. No details have been given yet. I'd like to know if anyone has experience with any of these. Our company is looking into re-using code using these solutions if possible, rather than re-writing the same functionality in Objec

Disable scrolling in an iPhone web application?

Is there any way to completely disable web page scrolling in an iPhone web app? I've tried numerous things posted on google, but none seem to work. Here's my current header setup: <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;"/> <meta name="apple-mobile-web-app-capable" content="yes"/> document.body.addEventListener('touchmove', function(e){ e.preventDefault(); }); doesn't seem to work.

Developing for iPhone or Android? (As a C# developer)

I'd like to start developing for iPhone or Android in my spare time, as a chance to learn something new but also hoping make some extra income. I'm not sure which is the best development for me to start developing on. I own an iPhone, but I don't have a Mac (which I would need to use the SDK), plus with the iPhone I believe there's an annual charge to develop for it. As far as I understand Android, the SDK is free and can be used on Windows. Professionally I develop using .net and C#, which sounds more similar to the Java based Android enviroment. Another negative I perceive against iPhone is it has a much more crowded App Store, I would think apps get better exposure on Android?

Force a WebView link to launch Safari?

I have a UIWebView embedded within an iPhone app of mine. I want to be able to have certain links within that webview open into the full Mobile Safari app (i.e. not my embedded version of it). Is there a simple way to structure some of my hrefs to force this, instead of every link opening within my embedded webview? Thanks.

Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape?

I have an application in which I would like to support multiple orientations. I have two .xib files that I want to use, myViewController.xib and myViewControllerLandscape.xib. myViewController.xib exists in project/Resources and myViewControllerLandscape.xib exists in the root project directory. What I want to do is use a separate NIB (myViewControllerLandscape.xib) for my rotations. I try detecting rotation in viewDidLoad like this: if((self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)) { NSLog(@"Landscape detected!"); [self initWithNibName:@"myViewControllerLandscape" bundle:nil]; } But I can see in gdb that this isn't executed when the app is started with the device in landscape. The NSLog message doesn't fire. Why is this? What have I done wrong? Also, if I explicitly put the initWithNibName function call in the viewDidLoad method, that nib is not loaded,

Create UIActionSheet "otherButtons" by passing in array, not varlist

I have an array of strings that I want to use for button titles on a UIActionSheet. Unfortunately, the otherButtonTitles: argument in the method invocation takes a variable length list of strings, not an array. So how I can I pass these titles into the UIActionSheet? The workaround I've seen suggested is to pass nil into otherButtonTitles:, then specify the button titles individually by using addButtonWithTitle:. But this has the problem of moving the "Cancel" button to the first position on the UIActionSheet rather than the last; I want it to be the last one. Is there a way to 1) pass an array in lieu of a variable list of strings, or alternatively 2) move the cancel button to the bottom of the UIActionSheet? Thanks.

Detect UDID spoofing on the iPhone at runtime

Jailbroken iPhones get on my nerve as it taints some fundamental APIs on iOS, by using MobileSubstrate. http://www.iphonedevwiki.net/index.php/MobileSubstrate I believe many apps use UDID as a mean to authenticate a device and/or a user since it's semi-automatic and handy, but you should be aware of this problem: UIDevice is not as tamper-proof as it should be. There's an app called UDID Faker, which easily enables you to spoof someone else's UDID at runtime. http://www.iphone-network.net/how-to-fake-udid-on-ios-4/ Here's the source code of it: // // UDIDFaker.m // UDIDFaker // #include "substrate.h" #define ALog(...) NSLog(@"*** udidfaker: %@", [NSString stringWithFormat:__VA_ARGS__]); #define kConfigPath @"/var/mobile/Library/Preferences/com.Reilly.UDIDFaker.plist" @protocol Hook - (NSString *)orig_uniqueIdentifier; @end NSString *fakeUDID = nil; static NSString *$UIDevice$uniqueIdentifier(UIDevice<Hook> *self, SEL sel)

Prefixing property names with an underscore in Objective C

I've always avoided underscores in my variable names, perhaps because its just not what was done back in my learning Java in college days. So when I define a property in Objective C this is what I naturally do. //in the header @interface Whatever { NSString *myStringPorperty } @property (nonatomic, copy) NSString *myStringProperty; //in the implementation @synthesize myStringProperty; But in almost every example it is done like //in the header @interface Whatever { NSString *_myStringPorperty } @property (nonatomic, copy) NSString *myStringProperty; //in the implementation @synthesize myStringProperty = _myStringProperty; Should I get over my aversion to the underscore because that is the one way it should be done, is there a good reason for this style being the preferred one?

Bundle Name, Executable Name, Product Name&hellip;anything else?

Bundle Name, Executable Name, Product Name... any more?? can someone please help clarify the use of each of these in Xcode on an iPhone project? They never fail to confuse the living bajezus out of me...and Im tired of getting them wrong. Someone please explain... why the hell do we need this many different naming schemes for one app environment? and what do I use each of these for so I can stick them in the right cubby hole in my head?

Great UIKit/Objective-C code snippets

New to Objective-C iPhone/iPod touch/iPad development, but I'm starting to discover lots of power in one-liners of code such as this: [UIApplication sharedApplication].applicationIconBadgeNumber = 10; Which will display that distinctive red notification badge on your app iphone with the number 10. Please share you favorite one or two-liners in Objective-C for the iPhone/iPod touch/iPad here. PUBLIC APIs ONLY .

How to use MallocStackLogging on the device?

I've a memory issue in an iPhone app that I'd like to debug with MallocStackLogging . The error involves the gyroscope so I have to debug on the device not the simulator. I've set the MallocStackLogging environment variable and the iPhone properly records the mallock stack logs: MyApp(1856) malloc: recording malloc stacks to disk using standard recorder MyApp(1856) malloc: stack logs being written into /private/var/mobile/Applications/1FD1F8D2-5D30-4AA7-B426-C52FE20266DE/tmp/stack-logs.1856.MyApp.index MyApp(1856) malloc: Please issue: cp /private/var/mobile/Applications/1FD1F8D2-5D30-4AA7- B426-C52FE20266DE/tmp/stack-logs.1856.MyApp.e8z3IL.link /tmp/ Now how can I work with them? I can transfer them to the Mac using the Xcode Organizer. But what should I do with these two files? stack-logs.1856.MyApp.index stack-logs.1856.MyApp.e8z3IL.link I tried moving the files in /tmp on the Mac and called: $ malloc_history 1856 -all_events malloc_history cannot exa

How to target iPhone 3GS AND iPhone 4 in one @media query

I am trying to implement alternate layouts for both the iPad/iPhone and older iPhones as well. I have established that the best method is to use @media queries from the CSS3 spec, As such these are my media queries at the minute: @media screen and (max-width: 1000px) { ... } Above is for small desktop and laptop screens. @media screen and (max-width: 700px) { ... } Above is for the iPad and VERY small desktop/laptop screens. @media screen and (max-device-width: 480px) { ... } Above is for iPhone 3GS- and mobile devices in general. However, the new iPhone 4 with Steve Jobs's all-singing all-dancing "retina" display means that it has a pixel ratio of 2-1 meaning 1 pixel actually appears to the browser as 2x2 pixels making its resolution (960x640 - meaning it will trigger the iPad layout rather than the mobile device layout) so this requires ANOTHER media query (only so far supported by webkit): @media screen and (-webkit-min-device-pixel-ratio: 2) { ... } N

Issue with iphone sdk 4.2.1

Probably a silly question. When running my project on the Device in the debug mode I get a lot of warnings al having the following string: warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148a)/Symbols/System/Library/PrivateFrameworks/ I think its due to the space between "4.2.1" and "(8C148a)". How can i get rid of it? It must be a setting somewhere in Xcode. I dont have these warnings on the simulator. thanks in advance, Christian

Learning OpenGL ES 1.x

What is the quickest way to come up to speed on OpenGL ES 1.x? Let's assume I know nothing about OpenGL (which is not entirely true, but it's been a while since I last used OpenGL). I am most interested in learning this for iPhone-related development, but I'm interested in learning how it works on other platforms as well. I've found the book OpenGL ES 2.0 Programming Guide , but I am concerned that it might not be the best approach because it focuses on 2.0 rather than 1.x. My understanding is that 2.0 is not backwards-compatible with 1.x, so I may miss out on some important concepts. Note: For answers about learning general OpenGL, see http://stackoverflow.com/questions/62540/learning-opengl Some resources I've found: http://khronos.org/opengles/1_X/ http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES1xMBX.asp OpenGL Distilled by Paul Martz (a good refresher on OpenGL basics)

While sending SMS, application is crashing

I want to send sms using below code in iPhone 4, but the application is crashing due to this code only. if ([MFMessageComposeViewController canSendText]) { MFMessageComposeViewController *smsComposerController = [[[MFMessageComposeViewController alloc] init] autorelease]; [smsComposerController setBody:@"First SMS"]; smsComposerController.recipients = [NSArray arrayWithObjects:@"9886333333",@"9980444444",nil]; smsComposerController.messageComposeDelegate = self; [smsComposerController release]; } I am new for SMS sending , so can any one help me what I am doing wrong?

"No previous prototype for function&rdquo; warning

i use shareKit to myself program . but in the FBConnectGlobal, there are some warning, NSMutableArray* FBCreateNonRetainingArray() { CFArrayCallBacks callbacks = kCFTypeArrayCallBacks; callbacks.retain = RetainNoOp; callbacks.release = ReleaseNoOp; return (NSMutableArray*)CFArrayCreateMutable(nil, 0, &callbacks); } like this method, it warning:"No previous prototype for function FBCreateNonRetainingArray"

Why is UIBezierPath faster than Core Graphics path?

I was playing around with drawing paths, and I noticed that in at least some cases, UIBezierPath outperforms what I thought would be a Core Graphics equivalent. The -drawRect: method below creates two paths: one UIBezierPath, and one CGPath. The paths are identical except for their locations, but stroking the CGPath takes roughly twice as long as stroking the UIBezierPath. - (void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); // Create the two paths, cgpath and uipath. CGMutablePathRef cgpath = CGPathCreateMutable(); CGPathMoveToPoint(cgpath, NULL, 0, 100); UIBezierPath *uipath = [[UIBezierPath alloc] init]; [uipath moveToPoint:CGPointMake(0, 200)]; // Add 200 curve segments to each path. int iterations = 200; CGFloat cgBaseline = 100; CGFloat uiBaseline = 200; CGFloat xincrement = self.bounds.size.width / iterations; for (CGFloat x1 = 0, x2 = xincrement; x2 < self.bounds.size.width; x1

Best way to use RestKit in an iPhone Application

I am writing an iPhone application and I have finally decided to use RestKit as the framework for connecting to REST Services. The way I am thinking of building is to have the Controllers in my application be completely agnostic to RestKit. For eg. If I had a login screen, in the usual RestKit scenario (based on example programs as well as few blog entries created by the RestKit developers) you will have the controller implement the RKRequestDelegate protocol and use the RKClient to call the service in the Controller passing self ( the controller) as the delegate. I would like to hide that from the User developing the Controllers and views. What I am thinking of is the following. I will have a LoginService which will login the user. There will be protocol LoginServiceDelegate which has two methods for success and failure. And the Controller can implement the LoginServiceDelegate and call the login Method in LoginService and get a success or failure callback. However to do this,