Skip to content
James Barrow edited this page Feb 11, 2015 · 4 revisions

SocialHelper

The social helper class allows quick access to some social aspects, such as presenting an email/message. This class has a private singleton it used for dleegate methods, so that every presenting view controller does not have to impliment them seperately.

toRecipients

Declaration

Swift

private var toRecipients: [String] = []

---

<br>

### ccRecipients


**Declaration**
> Swift  
> ```**swift**
private var ccRecipients: [String] = []


bccRecipients

Declaration

Swift

private var bccRecipients: [String] = []

---

<br>

### subject


**Declaration**
> Swift  
> ```**swift**
private var subject: String = ""


messageBody

Declaration

Swift

private var messageBody: String = ""

---

<br>

### isBodyHTML


**Declaration**
> Swift  
> ```**swift**
private var isBodyHTML: Bool = false


emailAttachments

Declaration

Swift

private var emailAttachments: [(data: NSData, mimeType: String, fileName: String)] = []

---

<br>

### messgaeAttachments


**Declaration**
> Swift  
> ```**swift**
private var messgaeAttachments: [(attachmentURL: NSURL, alternateFilename: String)] = []


viewController

Declaration

Swift

private var viewController: UIViewController?

---

<br>

### animated


**Declaration**
> Swift  
> ```**swift**
private var animated: Bool = true

Singleton


shared

Declaration

Swift

private class var shared: SocialHelper

---

<br>

### init()


**Declaration**
> Swift  
> ```**swift**
override private init()


clear()

Declaration

Swift

private func clear()


---

## Methods
<br>

### presentComposeViewController(_:initialText:urls:images:inViewController:animated:)
Presents a compose view controller with the details passed in.

**Declaration**
> Swift  
> ```**swift**
public class func presentComposeViewController(serviceType: String, initialText: String? = nil, urls: [NSURL]? = nil, images: [UIImage]? = nil, inViewController viewController: UIViewController, animated: Bool = true)

Parameters

`serviceType` The type of service type to present. For a list of possible values, see Service Type Constants.
`initialText` The initial text to show in the `SLComposeViewController`.
`urls` The URLs to attach to the `SLComposeViewController`.
`images` The images to attach to the `SLComposeViewController`.
`viewController` The view controller to present the `SLComposeViewController` in.
`animated` If the presentation should be animated or not.

Methods


phonePromptFormattedURL(number:)

Returns a NSURL to call with openURL(_:) in UIApplication parsed from a number string.

Declaration

Swift

public class func phonePromptFormattedURL(#number: String) -> NSURL?


**Parameters**
<table>
<tr><td> `number` </td><td> The number to parse in to create the URL. </td></tr>
<table>

**Return Value**  
The URL of the parsed phone number, prefixed with `telprompt://`.

---

<br>

### emailPrompt(toRecipients:ccRecipients:bccRecipients:subject:messageBody:isBodyHTML:attachments:viewController:animated:)
Creates a prompt for an email with the following parameters to pass into the `MFMailComposeViewController`.

**Declaration**
> Swift  
> ```**swift**
public class func emailPrompt(#toRecipients: [String], ccRecipients: [String] = [], bccRecipients: [String] = [], subject: String = "", messageBody: String = "", isBodyHTML: Bool = false, attachments: [(data: NSData, mimeType: String, fileName: String)] = [], viewController: UIViewController, animated: Bool = true)

Parameters

`toRecipients` The email addresses of the recipients of the email.
`ccRecipients` The email addresses of the CC recipients of the email.
`bccRecipients` The email addresses of the BCC recipients of the email.
`subject` The subject of the email.
`messageBody` The main body of the email.
`isBodyHTML` Tells the `MFMailComposeViewController` if the message body is HTML.
`attachments` The attachments to add to the email, passed in as a tuple of data, mime type and the file name.
`viewController` The view controller to present the `MFMailComposeViewController` in.
`animated` If the presentation should be animated or not.


presentMailComposeViewController(toRecipients:ccRecipients:bccRecipients:subject:messageBody:isBodyHTML:attachments:viewController:animated:)

Declaration

Swift

private class func presentMailComposeViewController(#toRecipients: [String], ccRecipients: [String], bccRecipients: [String], subject: String, messageBody: String, isBodyHTML: Bool, attachments: [(data: NSData, mimeType: String, fileName: String)], viewController: UIViewController, animated: Bool)


---

<br>

### messagePrompt(recipients:subject:body:attachments:viewController:animated:)
Creates a prompt for a message with the following parameters to pass into the `MFMessageComposeViewController`.

**Declaration**
> Swift  
> ```**swift**
public class func messagePrompt(#recipients: [String], subject: String = "", body: String = "", attachments: [(attachmentURL: NSURL, alternateFilename: String)] = [], viewController: UIViewController, animated: Bool = true)

Parameters

`recipients` The recipients of the message.
`subject` The subject of the message.
`body` The main body of the message.
`attachments` The attachments to add to the message, passed in as a tuple of attachment URL and alternate filename.
`viewController` The view controller to present the `MFMailComposeViewController` in.
`animated` If the presentation should be animated or not.


presentMessageComposeViewController(recipients:subject:body:attachments:viewController:animated:)

Declaration

Swift

private class func presentMessageComposeViewController(#recipients: [String], subject: String, body: String, attachments: [(attachmentURL: NSURL, alternateFilename: String)], viewController: UIViewController, animated: Bool)


---

## Methods
<br>

### mailComposeController(_:didFinishWithResult:error:)


**Declaration**
> Swift  
> ```**swift**
public func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!)

Methods


messageComposeViewController(_:didFinishWithResult:)

Declaration

Swift

public func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult)


---

## Methods
<br>

### alertView(_:clickedButtonAtIndex:)


**Declaration**
> Swift  
> ```**swift**
public func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int)

Clone this wiki locally