Various Scripts and Application Code Segments for .NET, VB, C#, C++, C, Java, JavaScript, HTML, Python, Perl, AutoIT, Batch, ASP Classic, Objective-C, Swift, Unreal Engine 4, Unity3D & others. Also contains numerous IT tidbits, procedures, and tricks including Technology Hacks on various platforms.
You can display an AlertPanel even if you have a strictly command line app. In the example below it shows a NSPanel called from pure C. id app = NULL; id pool = (id)objc_getClass("NSAutoreleasePool"); if (!pool) { return -1; } pool = objc_msgSend(pool, sel_registerName("alloc")); if (!pool) { return -1; } pool = objc_msgSend(pool, sel_registerName("init")); app = objc_msgSend((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication")); NSRunAlertPanel(CFSTR("Test"), CFSTR("Your App is running!"), CFSTR("Ok"), NULL, NULL); objc_msgSend(pool, sel_registerName("release"));
This example shows you how to download a remote file into an iOS Documents Directory from your iOS device. This is helpful for updates, and persisting data into your application, to replace static data. This allows you to keep your data fresh and dynamic.
In Objective-C / Cocoa to grab a substring from an NSString based on beginning and ending characters is easy. This is helpful if you want to parse HTML, JSON, or a REST statement returning. See below:
UIStroryBoard when you push view controllers, or segues, it doesn't
let you customize too much. What I ended up doing was override the
perform method and used QuartzCore Animations to customize our
transitions. I subclassed UIStoryBoardSegue and overwrote the perform
function.
Below to customize for Push or Pop then for Segues. (For segues remember to change the class to the custom class in IB).
To do it from a normal pop or push (this does cross fade animation, adjust it for yours):
This simple script tells the Game/App from Unity to shake/vibrate the Device if iOS/Android. If the device doesn't support vibrate, it'll simply do nothing!:
With this simple coding you can play a playlist on your device from your Unity3D Game. Why license royalties when you can get the user to do it for you per individual basis. I am using this in my game Snowboarding+ (see gameplay demo above). If there is no music on your device it'll finally play the local music in your Unity 3D app. This plays the playlist called Snowboarding+
in AppController.mm (also add MediaPlayer.framework):