iOS application version number in MonkeyTalk Test result XML file - monkeytalk

I am currently testing my iOS app using MonkeyTalk, and i am trying to identify the version number of my app within the XML file that Monkeytalk generates after test.

What you could see in the result XML file are the things that MonkeyTalk core framework does support by default. You may need to use "Exec()" command in your test script to achieve the goal.
As you've already known, in objective-c these 2 lines will give you the information you need:
NSString *versionNo = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleShortVersionString"];
NSString *buildNo = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleVersion"];
Here is the information about "Exec()" command, in both MT language and Javascript:
https://www.cloudmonkeymobile.com/monkeytalk-documentation/monkeytalk-language-reference/command-reference
Good luck! :)
P/S: For better support, you may need to post your question in MonkeyTalk forum:
https://www.cloudmonkeymobile.com/monkeytalk/forum

Related

OSX Quicksilver plugin, Objective C guidance

I'm attempting to modify a Quicksilver plugin (screen capture) in Xcode, in order to allow the screencapture destination path to be set to the defaults com.apple.screencapture path value. The plugin currently has the path hardcoded for some reason, so even when you've changed the OSX default path for screen captures, the plugin still sends them to the OSX default, which is the desktop.
I'm a literal noob with Xcode/Objective C, so any info/examples or point in the right direction would be much appreciated.
The screencapture plugin file which needs to be tweaked is the "QSScreenCapturePlugIn.m" file - here's a snippet:
(QSObject *)captureRegion:(QSObject *)dObject{
NSString *destinationPath=[#"~/Desktop/Picture.png" stringByStandardizingPath];
destinationPath=[destinationPath firstUnusedFilePath];
NSTask *task=[NSTask launchedTaskWithLaunchPath:SCTOOL arguments:[NSArray arrayWithObjects:#"-is",destinationPath,nil]];
[task waitUntilExit];
[[QSReg preferredCommandInterface] selectObject:[QSObject fileObjectWithPath:destinationPath]];
[[QSReg preferredCommandInterface] actionActivate:nil];
return nil;
}
I've searched high and low for examples demonstrating how to read from the defaults database, but it seems information is sparse.
Thanks!
I can't believe no one was able to help out with an answer or pointer on this one (or maybe I'm just not patient enough), but thankfully I was able to find the answer while reading through some other answers here on SO - unfortunately I can't reference the Question here, since I lost the page.
Anyway, this will do it:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *screenCaptureLocationString = [[defaults persistentDomainForName:#"com.apple.screencapture"] valueForKey:#"location"];
Amazingly hard to find this info for some reason, but hopefully posting it here will help someone else.

Objective-C, programmatically detect i386, or x86_x64 architecture of binary?

Is there a way to programmatically detect/determine if a binary (separate from my application) has been compiled i386, x86_x64, or both? I imagine there is a way (obviously), although I really have no idea how. Any suggestions or advice would be appreciated, thank you.
EDIT: I found an example on the Apple developer website, although it's written in C and setup to be used more as a command line tool. If anyone would know how to implement it into my objective-c code that would be extremely helpful.
Example [C] code: CheckExecutableArchitecture
You can include the mach-o headers and simply load the binary and then check the mach_header. You should read the Mach-O format description from Apple for more info, it includes everything you need: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html
- (void)checkArchitecture {
NSArray *bundleArch = [[NSBundle bundleWithPath:#"/path/to/other/bundle"] executableArchitectures];
}

iOS Clean Bad XML

Sometimes we receive incorrect XML back from a web service. Are there any libraries out there for objective-c, and specifically for iOS that can clean up XML to make it valid for a parser? Something like NSXMLDocumentTidyXML but for iOS?
Take a look at TouchXML, specifically CXMLDocumentTidyXML. Being a JSON fan myself, I've never used it, but it seems to be capable of tidying up xml. You would do something like this:
CXMLDocument *xmlDoc = [[CXMLDocument alloc] initWithXMLString:#"<foo></bar>"
options:CXMLDocumentTidyXML
error:&theError];

Obj-C equivalent for mdfind?

Is there a way to do a Spotlight query, in Obj-C, similar to what mdfind does? I need to write a method with the following signature:
-(NSString *)mdfind:(NSString *)theFileToLookFor
where the returned NSString is the first path found by the search.
Any help will be really appreciated.
NSMetadataQuery is the wrapper around the Carbon-level MDQuery API, which is how one interacts with the user's spotlight database.
the apis are in CoreServices.framework. start with the ones which have the prefix MDQuery

How do I create a Numbers spreadsheet using objective-c?

I'm writing a Cocoa application and I'd like to generate a Numbers spreadsheet from my application using Scripting Bridge. I've generated the Numbers.h file and linked the ScriptingBridge.framework per the directions in Apple's Documentation. Below is the code I'm using to try to simply create a Numbers document and save it.
NSString *path = #"/Users/username/Desktop/Test.numbers";
NumbersApplication *numbers = [SBApplication applicationWithBundleIdentifier:#"com.apple.iWork.Numbers"];
[numbers activate];
NumbersDocument *document = [[[numbers classForScriptingClass:#"document"] alloc] initWithProperties:[NSDictionary dictionaryWithObjectsAndKeys:project.title, #"name", nil]];
[[numbers documents] addObject:document];
[document saveAs:nil in:[NSURL URLWithString:path]];
The code compiles and runs and when I try the saveAs:in: method I get the following error:
-[SBProxyByClass saveAs:in:]: object has not been added to a container yet; selector not recognized [self = 0x2005912e0]
Is there something else I have to do besides adding the document to the [numbers documents] array?
I'm open to using AppleScript, but I'd prefer to using the Scripting Bridge if I can.
Ehh, Numbers scripting with SB; two black arts for the price of one. I would suggest trying to do it in AppleScript first, in order to narrow down the problem a bit.
If it breaks in AS too, then either you've phrased the commands wrongly or there's a problem in Numbers. Since most application scripters use AppleScript, you'll find it easier to get help if you can present code they'll recognise.
If it works, then either your translation of the commands to ObjC is incorrect or there's a problem in SB. Having a working example in AS will provide a starting point for figuring out where things are going wrong.
You might also look into objc-appscript, which provides a more reliable, less obfuscated alternative to SB. Its ASTranslate tool makes it easy to translate working AS commands to ObjC syntax.
Numbers doesn't yet support creation of documents via Applescript. You have to use GUI scripting. The new version of Numbers is supposed to be out Jan 6, 2011 and (hopefully) will fix its severely limited Applescript support.