sending data between tweaks - ios7

I have a tweak with hooks to an app (tweak1)
The tweak is supposed to use a framework to execute some code.
Unfortunately within iOS7 I'm unable to do that.
However when the same code is executed in a separate tweak (tweak2) with hooks to springBoard, it runs just fine.
My question is possible for me to send a dictionary from the first tweak (tweak1) to tweak2 so it gets executed.
I think I need to use CPDistributedNotificationCenter. But not sure.
If that's the case, a helping suggestions or example would be greatly appreciated.
many thanks

CPDistributedNotificationCenter should work or you could just use NSDistributedNotificationCenter. It inherits from NSNotificationCenter, which we all know how to use.
Another solution I can suggest is CFMessagePort, which I'm using in my apps. I need to support iOS 4, which doesn't support NSDistributedNotificationCenter, so I ended up using CFMessagePort. It differs from notification model in that you can't send messages to everyone. You can only send messages between two known ports. But in your case it probably doesn't matter.
There is also the XPC API but I've never used it and can't say much about it. It's an IPC API so it should work. Many iOS components use it.

Related

Cocoa: Launch Agent with Objects?

TLDR; is it possible to send/receive objects between an app and a 3rd party launch agent?
I'm writing an extension for an existing app (A). It's packaged and I do not have access to the source - but I can write simple plug-ins that can do some basic Cocoa and host a UI. Read: very limited options.
Ideally, what I'd like to do is have the plugin in app (A) message an external service (B) [sending objects], have (B) do some heavy lifting, then respond back to (A) so the UI can update.
I've been reading up on Launch Agents and they look promising, but I noted the examples all use basic types - no objects. I found one post discussing how to use Distributed Objects, but that's about it. It looks great, but what worries me is I'm not seeing a whole lot of current information on DO and I can't tell if it's something Apple will continue to support going forward.
Does anyone have any suggestions on options for a scenario like this? Maybe I'm just approaching this the wrong way?
Another option is I just completely split this out - write a separate full app and have (A) open it up with AppleScript. The UX wouldn't be as nice, but it would also work.
Thank you,
Eric
NOTE: I can't use NSTask. Or at least I've failed utterly to get it to work in this specific situation. Due to issues with app (A) it breaks when some of the methods run within the process. If I could somehow spawn NSTask so it was executing completely outside of (A) that might be an option. Which is actually what prompted me to look at Launch Agents...

Multi-peer connectivity without BrowserViewController UI

I am using Multi-peer connectivity framework and have tried Apple example it works fine, but I want to modify it and instead of using inbuilt browser view controller UI i want to do it with my own UI / code , is it possible to discover devices without the inbuilt UI ?
Please help.
See my answer here. I think you'll find the answer there but the short of it is that it is possible. Here is a link to a post at NSHipster that will walk you through the work too.

iOS Push Notification/Framework issue

I've been checking around the net to find some information or source code to achieve this. The thing is, that the Application I am developing uses a custom framework we are also developing. And our customer wants to add Push Notification support for the App.
But he wants the Framework we created to handle the Push Notifications (rather than the App). The following graph will explain a bit better the situation:
The problem is that the AppDelegate seems to be the only handling the Notifications from the OS, so the only solution I can think of is the App forwarding the notifications that come from the OS to the Framework. Any ideas or thoughts? Am I missing something?
Txs in advance
You will have to forward the calls. It should only require a few lines of code added to the appdelegate to interface with your framework though.
You could also do a hacky and more advanced approach where you swamp the IMP's of the AppDelegate methods and forward them through your framework. Just make sure you call the original imp once you're framework has done what it needs to. I wouldn't recommend this approach though as it may not remain stable for future ios versions.
Forwarding the calls is the way to go in my opinion.

Importing Code From Online

I know its a bit of a far fetched question.
But is it possible to import code from online, like say I had a .h and .m file on my website server and in the code I wanted to use it would I be able to import it? And How?
I ask this because it makes it loads easier to update an app if all they need to do is reload the app and the app changes to the latest version.
If you're talking about a Mac OS X application, then yes it's possible. No need to share your source code, just compile on the server and have the app download the new binary.
However, if your App needs to go through the App Store, which is necessary for iOS apps, then this surely is not possible. The only thing you can do is streamline the submission process as much as possible (see this question).
If you love the idea of being able to push new code at any time, consider making a web app. There's lots of stuff you can do these days.
I'm not 100% (maybe 95%) sure but I think storing objc code online to keep it auto-upgradable is not possible since the app isn't able to rebuild itself.
But if you want you could do a generic app that firstly fetches an XML/plist (for example) stored online to retrieve data and the app is set to read it and present different behaviours depending on that, but you'll have to code it previously in a generic way to support dynamic changes.
Hope this helps.

Web application programming using objective-c?

Just say you have a quite large and complicated desktop application written in objective-c/cocoa written properly in MVC. You then wish to replace the V and C so that it is a web application?
Is there anything like Tomcat but for objective c? The closest thing I can think of is somehow convert the Model code into an apache module to load in apache?
Obviously I could embed some sort of HTTP server and write a whole pile of code to manage sessions and requests and responses and so on, but might there be a simpler way?
You can leave the server almost as-is. I'd run it as a daemon in the background.
I'd split the controller part. One part of it resides on the server as a connection between HTTP requests and the daemon.
You could run a self-made http server.
You could build it into a Apache module as you mentioned.
You could access your controller through CGI. This is the easiest option as I see it.
The second part of the controller is written in Javascript in the browser, exchanging data with the server and updating the GUI.
The view part is written completely in javascript.
You could - if you want - leave out the controller on the server and make the model understand HTTP requests.
For the Controller / View part consider using a framework.
jQuery for only a light interface. (Or a similar framework.)
I haven't yet found a framework that leaves all the model stuff to the server. Maybe you can use SproutCore or Cappuccino accordingly.
SproutCore, the full-backed MVC framework that is used by Apple. (Think so at least.)
Cappuccino, another full-backed MVC framework.
Have you looked at Cappuccino? http://cappuccino.org/
I have not used but have heard many good things about it.
There is a new web development platform for Objective-C/Cocoa called Bombax. It sounds like exactly what you're looking for (it is designed to allow you to write entire web applications in Objective-C). Perhaps you could even combine it with Cappuccino. You can check it out at http://www.bombaxtic.com.
The closest you'll probably come to Objective-C web frameworks are either SOPE, or GNUStep, neither of which I have used, but ran across when I was deciding if I wanted to use Rails or something written in Objective-C for my web stuff. There's also ARJDatabase, which is kind of like Core Data, but not source compatible.
The bottom line is, unless you were very careful about how you wrote your code (i.e. wrote it with GNUStep in mind, didn't use anything Apple specific) you're probably going to have to do quite a bit of work anyway. And if you used Core Data at all, there's no way I know of to reuse that outside of a Mac App. And since it's not setup to be used my multiple simultaneous users, you wouldn't want to use that in a web app anyway. Bottom line, I went with Rails.
There is Frothkit - http://code.google.com/p/frothkit/ but it appears not to have been updated for a year.