This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Parsing a date in the following format '//2014-07-13T20:35:47.000Z' | |
//Use the DateFormat of @"yyyy-MM-dd'T'HH:mm:ss.zzz'Z'" | |
- (NSString *)formattedDate { | |
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.zzz'Z'"]; //2014-07-13T20:35:47.000Z | |
NSDate *tempDate = [dateFormatter dateFromString:self.date]; | |
[dateFormatter setDateFormat:@"EE MMM, dd"]; | |
return [dateFormatter stringFromDate:tempDate]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)formattedTime { | |
int seconds = [self.duration intValue] % 60; | |
int minutes = [self.duration intValue] / 60; | |
int hours = [self.duration intValue] / 3600; | |
return [NSString stringWithFormat:@"%02d:%02d:%02d", hours, minutes, seconds]; | |
} | |
//Better solution | |
- (NSString *)timeFormatted:(int)totalSeconds{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL: http://gdata.youtube.com/feeds/api/users/unpluggedacoustic1/uploads/?alt=json | |
JSON: | |
"media$group":{ | |
"media$thumbnail": [ | |
{ "url":"http://i.ytimg.com/vi/OKJk4QVyUTw/0.jpg","height":360,"width":480,"time":"00:01:39.500" }, | |
{ "url":"http://i.ytimg.com/vi/OKJk4QVyUTw/1.jpg","height":90,"width":120,"time":"00:00:49.750" }, | |
{ "url":"http://i.ytimg.com/vi/OKJk4QVyUTw/2.jpg","height":90,"width":120,"time":"00:01:39.500" }, | |
{ "url":"http://i.ytimg.com/vi/OKJk4QVyUTw/3.jpg","height":90,"width":120,"time":"00:02:29.250" } | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://www.appcoda.com/ios-programming-101-send-email-iphone-app/ | |
- (IBAction)sendEmail:(id)sender { | |
// Email Subject | |
NSString *emailTitle = @"iOS Email"; | |
// Email Content | |
NSString *messageBody = @"Sent from iOS App"; | |
// To address | |
NSArray *toRecipents = [NSArray arrayWithObject:@"unpluggedne@gmail.com"]; | |
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { | |
NSLog(@"url recieved: %@", url); | |
NSLog(@"query string: %@", [url query]); | |
NSLog(@"host: %@", [url host]); | |
NSLog(@"url path: %@", [url path]); | |
NSDictionary *dict = [self parseQueryString:[url query]]; | |
NSLog(@"query dict: %@", dict); | |
return YES; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *defaultPrefsFile = [[NSBundle mainBundle] pathForResource:@"defaultPrefs" ofType:@"plist"]; | |
NSDictionary *defaultPrefs = [NSDictionary dictionaryWithContentsOfFile:defaultPrefsFile]; | |
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultPrefs]; | |
//Get | |
NSString *strBaseURL = [[NSUserDefaults standardUserDefaults] stringForKey:@"BaseURL"]; | |
//Set | |
[[NSUserDefaults standardUserDefaults] setObject:baseURL forKey:@"BaseURL"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Button button = (Button) findViewById(R.id.button); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.myToolbar); | |
final WebView webView = (WebView) findViewById(R.id.webView); | |
//Set links to show in webview not open in another program. | |
webView.setWebViewClient(new WebViewClient()); | |
webView.getSettings().setJavaScriptEnabled(true); | |
String url = "http://www.alexhedley.com/form.asp"; | |
webView.loadUrl(url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import the various classes | |
// Add the controls to your View | |
Button button; | |
TextView tvScanResults; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_barcode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activity | |
android:name=".YourActivityName" | |
android:configChanges="orientation|screenSize" > | |
</activity> | |
//http://stackoverflow.com/questions/5913130/dont-reload-application-when-orientation-changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(EDITTEXT.getWindowToken(), 0); | |
//http://stackoverflow.com/questions/3553779/android-dismiss-keyboard |
OlderNewer