How can I override an Objective-C Cordova class without hacking the source? - objective-c

I am new to Objective-C so sorry if this is inanely simple. I am trying to alter the PhoneGap Capture Feature to add some text on the audio and video capture screens that pop up when you call capture.captureAudio and capture.captureVideo.
I have found I can alter the Cordova source and change the loadView method of the CDVAudioRecorderViewController to add a text field and alter the appearance. Likewise I imagine I should be able to do the same with the CDVImagePicker class.
I know hacking the source of a library is a bad idea so I am wondering what are the other simple ways I could go about doing this?
Is there a sneaky simple way to substitute an inherited class in Objective-C? Perhaps by changing a factory (init) method somehow? If so, how do I set this up within my own codebase so that it will use my changes ahead of the original code?
If not does that mean I have to resort to creating a plugin that overrides CDVCapture find every method that mentions the classes I want to sub out and replace them with my new class that inherits form CDVAudioRecorderViewController just to override a single method on CDVAudioRecorderViewController?

Related

Intellisense - deduce right Class by its methods

I'm used to work with NetBeans and now I'm trying IntelliJ. So my question is: Does IntelliJ has a way to get right class by its methods?
For example, in NetBeans if I write:
glGenBu // Intellisense will kick in and will suggest me
to use GL15.glGenBuffers() method from GL15 class
This will automatically import the right library.
This is very handy because I'm working with LWJGL and it has a bad way to manage OpenGL methods ('GLXX' where XX is the version of OpenGL and all methods that appeared in that version are stored in that class) and I never remember the right class where my desired method is.
Thank you.
Pressing Ctrl+Space when you already see completion list will show more suggestions, with static methods from the entire project among them. See https://www.jetbrains.com/help/idea/auto-completing-code.html for more details.

How can I extend a custom class ussing Architect?

I'm using Sencha Architect. I have already created a base class called MyApp.view.MyMenu that extends Ext.Menu.
How can I create a second class called: MyApp.view.MySecondMenu that extends MyApp.view.MyMenu. I cannot seem to be able to change the extend property!
Thank you!
PS: I'm using Architect v3.0.4.1386.
I found a solution:
In the Toolbox search for Class.
Drag the Class into the Project Inspector
Now you are able to modify the extend property :)
This is a problem in architect I really hate.
You have to add a custom class (you can do via the + in the corner of project Inspector) and there you can set the "extend property" to what you want.
The big disadvantage is that you don't have your properties in the inspector so you have to add every property you need as a custom one.
It's a kind of ugly workaround but the generated code is alright, hopefully they will better this one day.

How to add a new method in Smalltalk source code?

I am new to Smalltalk and I am trying to add a new method in the Integer class present in Smalltalk. The method should go in the 'accessor' protocol. I am using VisualWorks and not finding any option to do that. I have gone through the developers guide still its not clear to me. Can someone please give me screen shots or step wise solution about how to proceed with it?
Open your browser window [Small Talk Launcher --> System --> Browser]
Select a Package
Select a Class
Select a Protocol to which you want to add your new method.
You can find the tab "source" below the 4 partitions [Package, Class, Protocol, Method].
Replace the text in that "source" tab with the source code of your method.
Go to to "edit" option in the Browser menu.
Select "Accept" option.
Your new method is added successfully!
Cheers!
Aditya.
If you go into Smalltalk idea, you'll de that classes are objects as well and that you can just say class to compile a new method e.i. add a new method to itself:
Integer compile: 'getSomeVar ^someVar' classified: 'someVar'
_This will add to Integer in someVar protocol a method called getSomeVar that will return someVarinstance variable._
But for a general workflow you should use tools provided by Smalltalk environment such as a System Browser mentioned by Aditya Kappagantula

How to reference objects defined in another class?

I had my iPhone app working, developed with Storyboard. I decided to take all of the methods that belonged in a SQLite method and move them to a new SQLite class (.h and .m).
Now I have errors that I can't seem to get rid of. The basic problem is the textfields on the "scene" are now unreachable from the SQLite class (they are in another class, where they belong). The properties are defined in EDVController.m... I am trying to reach them from SQLite.m.
I have read the docs, but can't find anything that fits my problem.
How do I do this?
I give full credit to Jeremy Roman... I would up using NSMutableDictionary to pass the parameters, and it works like a champ! Thank you Jeremy and Jia Yow.

Methods best practice - VB.NET

I have a program that is getting pretty big and it is a pain to find everything through all the functions and classes.
I am trying to break it up into other files based on their method.
Some of these functions have calls to others in the main class. I changed most my functions from private to public to access this. I had problems calling certain code created windows so importing mainwindow helped that.
My last problem is editing the mainwindow ui from one of the module files. I want to make sure im on the right page before i continue breaking it up. My only guess is that anything they updates the ui should be left on the main class.
Thanks
The only code in your form class should be code that talks to other classes and updates the UI based on data from other classes.
Depending on your application, the form class might handle change events from other classes to update the UI or pass user input to other classes in Change or Click events.
A couple options:
Use callbacks into the your main window.
Create events for when you need the form updated. Your program logic raises the events, and your main window class can consume them.