Best practices for conversion from ASIHTTPRequest to AFNetworking? [closed] - ios

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm converting my app from ASIHTTPRequest to AFNetworking. What should I know, in broad strokes, about how these two frameworks are different and how my app should be structured differently? For example one thing that I have found is that ASIHTTPRequest is based around #selectors, and AFNetworking is based around GCD blocks.

You've already mentioned the most important part; the difference between delegate methods of ASI and blocks in AFN.
If you implemented the ASI methods in many different classes it's fairly straightforward to move those chunks into blocks inside the same classes when you switch to AFN. Otherwise, if you've implemented some grand class which deals with all your ASI networking, be prepared to copy and paste it into the calling classes. Overall, this should benefit you greatly as it reduces the amount of navigating you have to do when following the codepaths for your networking logic.
Also, if you've effectively written a wrapper against an API in ASI, you may want to consider subclassing AFHTTPClient and implementing common logic in such a subclass.

Related

Discussion, the best way in programming iOS? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I usually used to do every thing programmatically, what I mean is I am not using the Interface builder instead I do every thing in the code, like UIButton or UITableView, etc..
So can anyone tell me what is the best for programming iOS, or does that make any difference on the application performance or any thing else?
I am new to programming so I wanna hear that from someone in the field, I searched in Google but I couldn't find a clear answer.
Thanks.
The advantage of using IB is that it allows you make interface really quickly without checking a hundred times that a label should be moved up or down by pixel or two. But when you use IB you can't inherit nib files so if you have a lot of common interface features in several view controllers across your app you probably should use just code.
You really should separate your views from the code. This is what for Interface Builder was made for.
It builds xml files, apart from your application logic, so when you'll need to change anything in design you won't have to touch your code, and mess anything by mistake.
All modern program designs separate view from business logic: MVC, MVVM, MVP and so on. It is considered the best pattern for programming.

How can you tell if a MagicalRecord operation was successful? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I make heavy use of MagicalRecord for fetching, deleting, updating and saving data. I have noticed in testing that I don't get expected results because something went wrong with the operation I was attempting, such as a bad predicate resulting in no record being updated or deleted, etc.
I have looked at the available docs (such as they are) and can find nothing that give a method for examining any return code, etc.
Anyone know of a place that lists all of the available MR methods with explanations (other than the MR Categories and Core)?
I'm not exactly sure what it is you're looking for in the way of documentation. The primary reason for sparse documentation for the project is that the core data docs cover the vast majority of the features. Magical record is merely a set of convenience methods that make standard operations in core data much more manageable.
The parts that are 'non standard' core data functionality may need some extra explanation in how things work, but they source is also available to read and understand. If you have a specific question, please ask it.

what is mean by "this code is DRY" in ROR3? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I m new to ROR3.0 I was read a lot place saying that is "this code is DRY" or something related to DRY
I want to know how to make a code DRY ?
Is it necessary my code should be DRY?
DRY stands for Don't Repeat Yourself. If it's possible, it's good practice to use DRY in most coding environments to make it easy to maintain going forward (and stop your copy-paste keys getting worn out!)
I'd suggest wherever code is repeated to extract the common code and extract into a method.
The wiki below is a good place to see where a lot of these shorthand expressions came from:
http://c2.com/cgi/wiki?DontRepeatYourself
In this case, 'DRY' simply means 'Don't Repeat Yourself'. This simple guideline leads to writing smaller, better decomposed methods which can be reused in several contents. This in turn leads to easier maintenance, better testability etc.

Where can I find custom cocoa/xcode class files? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Kind of a noob question, but is there a good way to search for custom controls/objects/frameworks? I was able to stumble upon the Three20 framework and some other things like custom progress bar views and other custom views...but I just kinda 'happened' upon them. Is there any standard place where people post their stuff besides doing a github-wide search?
For UI elements, check out Cocoa Controls. I unfortunately don't know of any other centralized repositories for categories etc. All the useful stuff I've stumbled across came from github, stackoverflow, and/or repeated google searches.
I would recommend staying away from Three20, though. Having used it on some large projects in the past, the framework tended get in the way more than it helped IMHO. Their drawing libraries have some nice conveniences, but it's a lot of bloat to add to your project if you just want a single UI element that the framework provides.
One good site that has aggregated a lot of these is http://cocoacontrols.com/

Best method sequence for Ruby on Rails model? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In Rails, we offen write a lot of code in our models such as class methods, plugin methods, named_scopes, callbacks... I am wondering if there is a good pattern to organize the sequence. I saw the best example in a presentation before, but now I forgot.
Anyone have suggestion? Thanks
There is no set way... If you are using a scope (since Rails 3, named_scope is deprecated) that relies on a method, it has to be defined after the method in the model. It's possible to mix and match and sometimes it's necessary to do so.
It doesn't affect load time or efficiency to the best of my knowledge
I'm pretty OCD when writing ruby, so I have a very opinionated answer to your question. I created this gist as an example of the structure we use.
I wrote about that a while back as part of my style-guide:
acts_as_good_style.
YMMV as to what the "best" grouping/ordering is, but if you'd like my take it's there under the "Model idiom" section

Resources