It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Namaste! How often do you, experienced guys using generic pointers in daily routine and what's the common purpose for generic pointers in cocoa-touch development?
EDIT
A variable declared as a pointer to void is a generic pointer.
There's such thing. It may be set to an address of any variable type. I just want to know how the people use this kind of pointers in real life coding.
P.S Thank you for down voting.
There are fewer and fewer cases where void* is appropriate in ObjC. They're still used for some things like context pointers for KVO, but with the addition of ARC they're a pain to use even for that. Basically, if you need to ask when you would use a void*, you probably shouldn't use a void*. They're a little more common in the callbacks of Core frameworks, again usually for context pointers.
But to the question, "How often do you... [use void*] ... in daily routine," the answer is "very seldom, and as little as possible."
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I recently was asked this question in an interview and would like to hear the answer from you people.
I discussed about code resuability and security that can be achieved by encapsulation and inheritance but the interviewer did not seem satisfied.
He insisted on how exactly an application user is benefited by using applications developed on the principles of oop.
Depends. Purists (and morons) will apply abstraction to every possible bit of code they generate or come across. This is completely unnecessary in something as simple as a direct, simple MySQL call from within a tiny bit of PHP, to log site accesses, for instance.
However, generally OOP can save you plenty of cycles if applied systematically to big data involving lots of information shuffling, like sorting hundreds of rows of data on every page access. It's a matter of when to use OOP and when to just write procedural code. OOP takes time and effort and is maintainable by experienced programmers, but you need to ask yourself if it is worth all that extra hassle on a tiny snippet of code that does one thing internally.
There are plenty of good articles out there (http://berryllium.nl/2011/02/getters-and-setters-evil-or-necessary-evil/) that help you to understand WHY OOP is sometimes unnecessary and in fact harmful.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I would like to know, why is so important to write interface and implementation for every calss in Objective C. In other langauge this technique is only optional.
In Objective-C, writing an interface is also optional (so is declaring methods), although the compiler will likely warn you. Writing the interface permits somebody else to reuse the binary form of your code without having to recompile it; this way you can also hide the implementation details/the code from the one who reuses your class. Also, if only you use your own class, the compiler may need some information at compile time (although Objective-C is a dynamic language) about the classes you write -- in this case you can't include the whole implementation file as it would result in duplicating your entire class, redulting in a linker error. Same reason why there are header files for any C library out there.
Interface describes how other classes and their instances will interact with your class and its instances. You could just create implementation, but that would kind of defeat the purpose of OOP.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to implement an app that is a test of intelligence. Do I have to use CoreData, or what alternatives do I have?
If so, do you have a good CoreData tutorial or similar reference?
Thanks a lot!
CoreData is just a persistance layer. You can store your data in whatever medium works best for you.
Hardcoded in classes
In plists
In flat files
CoreData is nice because it gives you the full power of a relational database behind a set of abstraction classes that work well in an object orientated environment, but you never have to use it.
For learning CoreData I found the Marcus Zarra book to be good.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
As we know that the Object oriented programming language has lots of benefit.But in same implementation procedural language like C do not have any alternative like realtime applications. So can we combine the power of two to create a great application?
Can we experience the major pillars of OOPS in procedural language?
Nearly all general-purpose languages are Turing equivalent. This means -- among other thing -- that anything you can dream up in one language, you can implement in another. So yes, it's possible, though it isn't enforced by the compiler as strictly as an OOP zealot might like.
Consider C's FILE type (used by fopen, fread, fwrite, etc). It's not specified what exactly is in there, and you don't need to know or care (read: encapsulation); all you have to know is, you can fopen you a file, fread/fwrite it, and when you're done, you fclose. Thing is, that "file" can be anywhere -- at the root of the FS, in your homedir that's on a whole other drive...in most OSes, it can even be a pipe or a network socket (read: polymorphism).
Basically, the funnest parts of OOP. And we didn't say "class" even once. :)
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
With last version of iOS Apple has implemented Automatic Reference Counting for Objective-C, but I don't understand as works.
Automatic reference counting inserts retain and release messages into your code for you at compile-time, following the normal conventions. So it's exactly as if you did the memory management yourself manually, except that the compiler is smart enough to be able to write that bit for you, and much less likely to make a mistake.
So it's not garbage collection, it's more like a (very simple) form of static analysis. And you still get overwhelmingly deterministic memory management and little overall change in runtime costs, as per the caveats raised by Catfish_Man below.
Automatic Reference Counting implements automatic memory management for Objective-C objects and blocks, freeing the programmer from the need explicitly insert retains and releases. It does not provide a cycle collector; users must explicitly manage lifetime instead.
Read this spec - Automatic Reference Counting