Hacker News new | comments | ask | show | jobs | submit login
NSRails - Rails + Objective C Framework (nsrails.com)
30 points by nanijoe on May 23, 2012 | hide | past | web | favorite | 20 comments

The objective-c classes that are part of this framework are prefixed with NS which is reserved by Apple. I am not sure why they are using this prefix. Maybe they don't know objective-c very well or they don't care or whatever. I would love to hear a statement from the developer of NSRails what he has to say about that... Are you reading this?

I am reading! Really only one class is really prefixed with "NS" - everything else is prefixed with "NSR" which should solve any potential namespace issues.

I did consider this possibility but I think I preferred the elegance of plain NS, and still highly doubt that Apple will release or has any classes named NSRailsModel :) But I do absolutely agree, it's better to be on the cautious side. It's very likely that NSRailsModel will change in the future.

See the ticket posted somewhere in this thread for more details, I'd prefer to keep the discussion there.

I'm with you one this, I don't even know if Apple would approve apps using NS prefix without their consent.

Apple does not inspect your source code when an App is submitted. They only inspect the binary and the metadata of an App.

Not true, they scan the binary for symbols. I.e. they check for any usage of private api's. I doubt that they will reject an app just because of their usage of NS.. classes, but on the other hand if the NS... class accidentally has the same name of another internal private Apple API, the app will be rejected (Has happened to other developers already).

You should be stripping your binary of symbols. (-strip-all, -s)

I used the word "inspect" carefully. Apple is probably looking for calls to private APIs by looking at the addresses of functions called in your binary with the addresses of private APIs.

They are probably looking for method swizzling of Cocoa APIs by looking at the address passed into method_exchangeImplementations, class_replaceMethod, etc.

Looking at the symbols within a binary is probably more effort than it is worth and probably isn't going to be very effective.

The names of all of your classes and messages can be found with `strings` anyways, if they did want to reject based on those.

Yeah this is really bad form. Prefix needs changed for sure. It's a really cool project though!

edit: filed an issue here: https://github.com/dingbat/nsrails/issues/4

Not only that but this is an abstraction of ActiveRecord at best. This is just the M of the MVC. I strongly dislike it.

Hi - author here. I'm curious about your opinion, could you elaborate?

Edit: maybe you thought NSRails is an attempt to port Rails to iOS? Please see the readme - that's not the purpose of the framework. NSRails just allows iOS to talk to Rails simply and effectively.

Looking at the screencast I was surprised to see this macro syntax being allowed (passing an asterisk here means all properties get synced):

Here's what's happening. Ingenious stuff.

  //adding a # before va_args will simply make its contents a cstring
  #define _MAKE_STR(...)	NSRStringFromCString(#__VA_ARGS__)

  //define NSRailsSync to create a method called NSRailsSync, which returns the entire param list
  #define NSRailsSync(...) \
  + (NSString*) NSRailsSync { return _MAKE_STR(__VA_ARGS__); }


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”

Seeing the recent evolutions, I thought Rails people learned that magic in code leads to debugging unhappiness.

I think that quote is about complex code.

We tend to look at macros as dangerous, but this is a pretty clean usage of macros, it's basically a function that turns the arguments into a string. Simple and easy to debug. Don't you think?

Edit: Discussion about that quote: http://stackoverflow.com/questions/1103299/help-me-understan...

It’s a simple macro that makes you write code that looks like a syntax error, and I don’t like that (http://www.codinghorror.com/blog/2006/05/code-smells.html).

Especially since without the macro you’d just need to write two characters more or, even better, a clearly named constant, like kNSRAllProperties.

Are there any Javascript libraries that do this same thing? I know backbone.js does, but I am not looking for a full MVC stack.

Did you know that the Dutch rail company is called NS or is that just a coincindence?

NS is the NeXTSTEP class prefix in ObjC, I doubt they're doing anything more than copying that. They shouldn't.

Actually, NX is the NeXTSTEP class prefix.

The NS classes were introduced as part of OPENSTEP, which leads some people to suggest that NS = NeXT + Sun.

> The NS classes were introduced as part of OPENSTEP

This is incorrect - the NS prefix was introduced in NEXTSTEP along with EOF.


Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact