Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

best practices for cocoa touch static library [closed]

I'm planning to do my next project using cocoa touch static library. My target is to separate my model entirely from my main project. ( so it does all the data communication between server and provide data to my main project). so that I can reuse the library in future if there's any iphone version.

I want my framework to behave like ios standard frameworks so that no one else using my framework should not be able to play with framework and misuse it. Specially they should not be able to override data which is given by my framework and do any kind of data manipulation.(protecting encapsulation)

I want to know that are the best practises of writing a this kind of static library?

like image 528
Charith Nidarsha Avatar asked Dec 05 '25 10:12

Charith Nidarsha


1 Answers

From a language perspective you will want to carefully consider what is public method/member and what is private.

For all things private move them into the interface declaration inside your .m file:

@interface MyClass()
# Variables and Messages declared here are private.
@end

Then make a single header file which is exposed to your users with all public messages and properties.

When you do this be particularly careful that you document expectations of your users. Nothing will break encapsulation faster than expecting a capability / variable and not being able to see how to get it in the docs / header.

like image 89
Hasan Edain Avatar answered Dec 07 '25 00:12

Hasan Edain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!