Skip to content

Instantly share code, notes, and snippets.

View Mohamed-AbdulRaouf's full-sized avatar

Mohamed Abdul-Raouf Mohamed-AbdulRaouf

View GitHub Profile
@dobster
dobster / ExpandoTableViewCell.swift
Last active June 25, 2023 14:12
Expanding Table View Cell to reveal UITextView
//
// ExpandoTableViewCell.swift
// TestExpandoCells
//
import UIKit
protocol ExpandoTableViewCellDelegate: class {
func expandoTableViewCellDidTapCell(_ cell: ExpandoTableViewCell)
func expandoTableViewCell(_ cell: ExpandoTableViewCell, didChangeNotes notes: String)
@nunogoncalves
nunogoncalves / CreditCardValidation.swift
Last active October 7, 2021 07:51
Credit card validation in Swift 3
import UIKit
import PlaygroundSupport
//http://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number
enum CreditCardType {
case visa
case visaElectron
case mastercard
@alexkafer
alexkafer / makePhoneCall(phoneNumber: String) .swift
Last active January 31, 2022 21:40
Simple function to prompt a phone call on iOS in Swift
func makePhoneCall(phoneNumber: String) {
if let phoneURL = NSURL(string: ("tel://" + phoneNumber!)) {
let alert = UIAlertController(title: ("Call " + phoneNumber! + "?"), message: nil, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Call", style: .Default, handler: { (action) in
UIApplication.sharedApplication().openURL(phoneURL)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
@ashikahmad
ashikahmad / remove_unexpected_repo_from_xcode_source_control.md
Last active June 17, 2022 18:55
Removing unexpected repository from XCode source control

Here are the steps that should work for you:

This steps are copied from pocketlogic's answer at StackOverflow

  1. Quit Xcode, and make a backup of your project file ( projectName.xcodeproj ).
  2. In Finder, right-click on your project file and select Show Package Contents.
  3. Right-click on the project.xcworkspace file, and select Show Package Contents.
  4. In the folder named xcshareddata, there is a file with the extension .xccheckout (it should have the same name as your main project file, but with the .xccheckout extension). Open the .xccheckout file in your favorite plain-text editor - this is a plist.
  5. Find the IDESourceControlProjectWCConfigurations key, and look for the <dict> that has the name of the repository that you want to remove. In the same \ there is a key IDESourceControlWCCIdentifierKey whose value contains an i
@lamprosg
lamprosg / appDelegate.mm
Last active February 11, 2023 08:55
(iOS) Running location updates in the background
-(void) applicationDidEnterBackground:(UIApplication *) application
{
// You will also want to check if the user would like background location
// tracking and check that you are on a device that supports this feature.
// Also you will want to see if location services are enabled at all.
// All this code is stripped back to the bare bones to show the structure
// of what is needed.
[locationManager startMonitoringSignificantLocationChanges];