Monday, December 31, 2012
Friday, December 21, 2012
Undo last commit and re-commit
http://stackoverflow.com/questions/927358/git-undo-last-commit$ git reset --soft HEAD^ (1) $ git commit -c ORIG_HEAD (2)
Wednesday, December 5, 2012
Kill all xcode related processes
ps axww | grep -i xcode | cut -d " " -f1 | while read i; do kill -9 $i; done;
Saturday, November 17, 2012
Symbolicate crash files
#!/bin/shif [ $# -ne 2 ]thenecho "Usage: Copy 'app_name'.app and 'app_name'.app.dSYM into `dirname $0` and run"echo "`basename $0` app_name crash_file.crash"exit 1fiCRASH=$2APP=$1DEVELOPER_DIR=`xcode-select --print-path`export DEVELOPER_DIRSYMBOLICATE_PATH=${DEVELOPER_DIR}/Platforms/iPhoneOS.platform/Developer/Library//PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrashset -eCRASH_UUID=`grep --after-context=2 "Binary Images:" "${CRASH}" | grep "${APP}" | grep -o "<.*>" | sed -E "s/<(.*)>/\1/"`echo "Found crash UUID: \"${CRASH_UUID}\""APP_UUID=`dwarfdump --uuid ${APP}.app/${APP} | cut -d ' ' -f 2`echo "Found app UUID: \"${APP_UUID}\""DYSYM_UUID=`dwarfdump --uuid ${APP}.app.dSYM | cut -d ' ' -f 2`echo "Found dsym UUID: \"${DYSYM_UUID}\""echo "-----------------------------------"echo "UUID's must match ${CRASH_UUID} ${APP_UUID} ${DYSYM_UUID}"echo "-----------------------------------"mdfind "com_apple_xcode_dsym_uuids = *""${SYMBOLICATE_PATH}" "${CRASH}"
Thursday, November 15, 2012
Monday, October 29, 2012
Photoshop preferences location
Where is photoshop preferences located on OSX / Mac?
/Users/[user]/Library/Preferences/Adobe\ Photoshop\ CS3\ Settings/Adobe\ Photoshop\ CS3\ Prefs.psp
/Users/[user]/Library/Preferences/Adobe\ Photoshop\ CS3\ Settings/Adobe\ Photoshop\ CS3\ Prefs.psp
Thursday, October 4, 2012
Hide back button UINavigationItem
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.hidesBackButton = YES;
Wednesday, October 3, 2012
UINavigationController added as a subview not showing up in UIViewController
If your UINavigationController is not being shown as a subview, it might be named 'navigationController" which is the same as UIViewController's inherited object. Rename your custom navigationController to a different name to ensure it does not conflict with the inherited object.
I was bit in the butt by this when I switched my inherited class from UINavigationController to UIViewController.
Friday, September 28, 2012
Android - R cannot be resolved to a variable
Project Properties -> Google Apis (make sure it is checked). After each checkout / update from git, this is unchecked for my environment (for whatever reason.)
Project -> Clean
Project -> Build
Project -> Clean
Project -> Build
Wednesday, September 26, 2012
Friday, September 14, 2012
Can't interact with bottom screen iOS Retina 4 inch
If you cannot interact with the bottom portion of the new iPhone simulator, be sure you are setting the frame of the main window. If you configured the window with the nib, it defaults to 480 screen size, thus any UI objects located beyond the 480 screen size cannot be interacted with. To solve, in your launched app delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [window setFrame:CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height)];
Monday, September 10, 2012
UIGestureRecognizer being handled differently on iOS6 vs iOS5
Noticed that UIGestureRecognizer would still fire off in iOS5 after a UIButton was selected.
On iOS6, the UIGestureRecognizer would not fire off if the UIButton was selected.
On iOS6, the UIGestureRecognizer would not fire off if the UIButton was selected.
Friday, September 7, 2012
UIProgressBar download file
Helpful example of creating your own progress bar download. Utilizes connection:(NSURLConnection *) delegate methods:
http://www.developers-life.com/progress-bar-download-file-on-iphone.html
Critical components:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[self.receivedData appendData:data];
NSInteger receivedLen = [data length];
bytesReceived = (bytesReceived + receivedLen);
if(expectedBytes != NSURLResponseUnknownLength) {
self.progress = ((bytesReceived/(float)expectedBytes)*100)/100;
percentComplete = self.progress*100;
}
[delegate downloadBarUpdated:self];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[self.delegate downloadBar:self didFailWithError:error];
[connection release];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
expectedBytes = [response expectedContentLength];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self.delegate downloadBar:self didFinishWithData:self.receivedData suggestedFilename:localFilename];
[connection release];
}
http://www.developers-life.com/progress-bar-download-file-on-iphone.html
Critical components:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[self.receivedData appendData:data];
NSInteger receivedLen = [data length];
bytesReceived = (bytesReceived + receivedLen);
if(expectedBytes != NSURLResponseUnknownLength) {
self.progress = ((bytesReceived/(float)expectedBytes)*100)/100;
percentComplete = self.progress*100;
}
[delegate downloadBarUpdated:self];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[self.delegate downloadBar:self didFailWithError:error];
[connection release];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
expectedBytes = [response expectedContentLength];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self.delegate downloadBar:self didFinishWithData:self.receivedData suggestedFilename:localFilename];
[connection release];
}
Thursday, September 6, 2012
Fitting all map annotations for display iOS
If you support iOS4+, use the method of creating a MKMapRect to display
If you need to support iOS3, loop through the annotations to find the top left and bottom most right annotation to figure out largest region to display:
MKMapRect zoomRect = MKMapRectNull;
if ([mView.annotations count] == 0) return;
NSInteger count=0;
for (id <MKAnnotation> annotation in mapView.annotations){
if( [annotation isKindOfClass:[MapViewAnnotation class]] && annotation.coordinate.latitude != 0 && annotation.coordinate.longitude != 0 ){
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
zoomRect = pointRect;
}
else {
zoomRect = MKMapRectUnion(zoomRect, pointRect);
}
count++;
}
}
MKCoordinateRegion region = MKCoordinateRegionForMapRect(zoomRect);
[mapView setRegion:region];
If you need to support iOS3, loop through the annotations to find the top left and bottom most right annotation to figure out largest region to display:
CLLocationCoordinate2D topLeftCoord;
topLeftCoord.latitude = -90;
topLeftCoord.longitude = 180;
CLLocationCoordinate2D bottomRightCoord;
bottomRightCoord.latitude = 90;
bottomRightCoord.longitude = -180;
NSInteger i=0;
for(MapViewAnnotation *annotation in mView.annotations) {
if(
([annotation isKindOfClass:[MapViewAnnotation class]] || [annotation isKindOfClass:[MKPointAnnotation class]] == includeKml)
&& (![annotation isKindOfClass:[MKUserLocation class]])
){
topLeftCoord.longitude = fmin(topLeftCoord.longitude, annotation.coordinate.longitude);
topLeftCoord.latitude = fmax(topLeftCoord.latitude, annotation.coordinate.latitude);
bottomRightCoord.longitude = fmax(bottomRightCoord.longitude, annotation.coordinate.longitude);
bottomRightCoord.latitude = fmin(bottomRightCoord.latitude, annotation.coordinate.latitude);
i++;
}
}
MKCoordinateRegion region;
region.center.latitude = topLeftCoord.latitude - (topLeftCoord.latitude - bottomRightCoord.latitude) * 0.5;
region.center.longitude = topLeftCoord.longitude + (bottomRightCoord.longitude - topLeftCoord.longitude) * 0.5;
region.span.latitudeDelta = fabs(topLeftCoord.latitude - bottomRightCoord.latitude) * 1.1;
// Add a little extra space on the sides
region.span.longitudeDelta = fabs(bottomRightCoord.longitude - topLeftCoord.longitude) * 1.1;
// Add a little extra space on the sides
region = [mView regionThatFits:region];
[mView setRegion:region animated:YES];
Convert pixel length to latitude longitude difference iOS
// 1. Get difference from center of map to top middle of map (200 pixel difference).
// 2. Convert this pixel difference into difference of latitude
// 3. Reset the mapView center point with the new offset
//Grab the pixel difference from the center of the mapview
CGPoint centerOfMap = CGPointMake(mapView.frame.size.width/2, mapView.frame.size.height/2);
CGPoint topMidOfMap = CGPointMake(centerOfMap.x, centerOfMap.y-200); //Step 1
//Now get difference of longitude and latitude
CLLocationCoordinate2D centerOfMapCoord = [mapView convertPoint:centerOfMap toCoordinateFromView:mapView]; //Step 2
CLLocationCoordinate2D topMidOfMapCoord = [mapView convertPoint:topMidOfMap toCoordinateFromView:mapView]; //Step 2
CGFloat latitudeDiff = topMidOfMapCoord.latitude - centerOfMapCoord.latitude; //Step 2
coord.latitude -= latitudeDiff;
[mapView setCenterCoordinate:coord zoomLevel:default_zoom animated:NO]; //Step 3
Wednesday, September 5, 2012
Converting screen size (pixels) to Longitude Latitude
http://stackoverflow.com/questions/11019965/convert-screen-size-pixels-to-latitude-longitude
Tuesday, September 4, 2012
iPhone 5 Resolution Hack crash
Modifying the plist file directly:
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/Resources/Devices/iPhone (Retina).deviceinfo/Info.plist
May cause XCode to crash, most likely due to permission issues. Copy the Info.plist file into a temporary directory first. Modify the copied Info.plist file with XCode, then copy back into the directory using sudo.
Original article:
http://www.ijailbreak.com/how-to/run-apps-640-x-1136-iphone-5-resolution-hack/
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/Resources/Devices/iPhone (Retina).deviceinfo/Info.plist
May cause XCode to crash, most likely due to permission issues. Copy the Info.plist file into a temporary directory first. Modify the copied Info.plist file with XCode, then copy back into the directory using sudo.
Original article:
http://www.ijailbreak.com/how-to/run-apps-640-x-1136-iphone-5-resolution-hack/
iOS Auto resizing subviews
I have the parent view: self.view and a subview: UIImageView *pinView.
I would like pinView resize when self.view becomes resized. To accomplish this:
[pinView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
Early attempts that did NOT work:
[self.view setAutoresizesSubviews:YES];
[self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
You will need to apply the autoresize mask to the subview you want resized.
Wednesday, August 22, 2012
Simulate Slow Connection / Throttling Connection
Helpful command to test against low connections (mimicking 3G or worse):
OSX:
sudo ipfw add pipe 1 src-port http
ipfw pipe 1 config delay 200 bw 300kbit/s
To restore your connection:
ipfw flush
OSX:
sudo ipfw add pipe 1 src-port http
ipfw pipe 1 config delay 200 bw 300kbit/s
To restore your connection:
ipfw flush
Thursday, June 28, 2012
IOS 6 TWTweetComposeViewController canSendTweet Bug
[TWTweetComposeViewController canSendTweet] seems to be returning false always on iOS6. Anyone have additional information or experiencing the same problems?
Thursday, June 7, 2012
Friday, March 23, 2012
What do I have to do to get Core Data to automatically migrate models?
http://stackoverflow.com/questions/1018155/what-do-i-have-to-do-to-get-core-data-to-automatically-migrate-models
Wednesday, February 8, 2012
Using Kindle Fire as an Android Dev test device
http://mobile.tutsplus.com/tutorials/android/getting-started-with-kindle-fire-development/
Subscribe to:
Posts (Atom)