Thursday, July 31, 2014

Namespace: MonoTouch Xamarin

Namespace: MonoTouch.AVFoundation

Type Changed: MonoTouch.AVFoundation.AVAsset

Removed:
1
2
3
4
  public virtual AVAssetResourceLoader ResourceLoader {
   get;
  }

Type Changed: MonoTouch.AVFoundation.AVAssetReaderVideoCompositionOutput

Removed:
1
2
3
  public AVAssetReaderVideoCompositionOutput Create (AVAssetTrack[] videoTracks, MonoTouch.CoreVideo.CVPixelBufferAttributes settings);
  public virtual AVAssetReaderVideoCompositionOutput WeakFromTracks (AVAssetTrack[] videoTracks, MonoTouch.Foundation.NSDictionary videoSettings);
Added:
1
2
3
  public static AVAssetReaderVideoCompositionOutput Create (AVAssetTrack[] videoTracks, MonoTouch.CoreVideo.CVPixelBufferAttributes settings);
  public static AVAssetReaderVideoCompositionOutput WeakFromTracks (AVAssetTrack[] videoTracks, MonoTouch.Foundation.NSDictionary videoSettings);

Type Changed: MonoTouch.AVFoundation.AVCaptureVideoPreviewLayer

Removed:
1
2
  public virtual string VideoGravity {
Added:
1
2
  public string VideoGravity {

Type Changed: MonoTouch.AVFoundation.AVPlayerLayer

Removed:
1
2
  public virtual string VideoGravity {
Added:
1
2
  public string VideoGravity {

Namespace: MonoTouch.AudioToolbox

Type Changed: MonoTouch.AudioToolbox.AudioChannelLayoutTag

Removed:
1
2
 public enum AudioChannelLayoutTag {
Added:
1
2
 public enum AudioChannelLayoutTag : uint {

New Type: MonoTouch.AudioToolbox.AudioConverter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
public class AudioConverter : IDisposable {
 
 public static AudioConverter Create (AudioStreamBasicDescription sourceFormat, AudioStreamBasicDescription destinationFormat);
 public static AudioConverter Create (AudioStreamBasicDescription sourceFormat, AudioStreamBasicDescription destinationFormat, AudioClassDescription[] descriptions);
 public static AudioConverter Create (AudioStreamBasicDescription sourceFormat, AudioStreamBasicDescription destinationFormat, out AudioConverterError error);
 public AudioConverterError ConvertBuffer (byte [] input, byte [] output);
 public AudioConverterError ConvertComplexBuffer (int numberPCMFrames, AudioBuffers inputData, AudioBuffers outputData);
 public void Dispose ();
 protected virtual void Dispose (bool disposing);
 public AudioConverterError FillComplexBuffer (ref int outputDataPacketSize, AudioBuffers outputData, AudioStreamPacketDescription[] packetDescription);
 protected override void Finalize ();
 public AudioConverterError Reset ();
 
 public static AudioFormatType[] DecodeFormats {
  get;
 }
 public static AudioFormatType[] EncodeFormats {
  get;
 }
 public AudioValueRange[] ApplicableEncodeBitRates {
  get;
 }
 public AudioValueRange[] ApplicableEncodeSampleRates {
  get;
 }
 public AudioValueRange[] AvailableEncodeBitRates {
  get;
 }
 public AudioChannelLayoutTag[] AvailableEncodeChannelLayoutTags {
  get;
 }
 public AudioValueRange[] AvailableEncodeSampleRates {
  get;
 }
 public int BitDepthHint {
  get;
  set;
 }
 public uint CalculateInputBufferSize {
  get;
 }
 public uint CalculateOutputBufferSize {
  get;
 }
 public bool CanResumeFromInterruption {
  get;
 }
 public int [] ChannelMap {
  get;
 }
 public AudioConverterQuality CodecQuality {
  get;
  set;
 }
 public byte [] CompressionMagicCookie {
  get;
  set;
 }
 public AudioStreamBasicDescription CurrentInputStreamDescription {
  get;
 }
 public AudioStreamBasicDescription CurrentOutputStreamDescription {
  get;
 }
 public byte [] DecompressionMagicCookie {
  get;
  set;
 }
 public double EncodeAdjustableSampleRate {
  get;
  set;
 }
 public uint EncodeBitRate {
  get;
  set;
 }
 public AudioFormat[] FormatList {
  get;
 }
 public AudioChannelLayout InputChannelLayout {
  get;
 }
 public uint MaximumInputPacketSize {
  get;
 }
 public uint MaximumOutputPacketSize {
  get;
 }
 public uint MinimumInputBufferSize {
  get;
 }
 public uint MinimumOutputBufferSize {
  get;
 }
 public AudioChannelLayout OutputChannelLayout {
  get;
 }
 public AudioConverterPrimeInfo PrimeInfo {
  get;
 }
 public AudioConverterPrimeMethod PrimeMethod {
  get;
  set;
 }
 public AudioConverterSampleRateConverterComplexity SampleRateConverterComplexity {
  get;
 }
 public double SampleRateConverterInitialPhase {
  get;
  set;
 }
 public AudioConverterQuality SampleRateConverterQuality {
  get;
 }
 
 public event AudioConverterComplexInputData InputData;
}

New Type: MonoTouch.AudioToolbox.AudioConverterComplexInputData

1
2
3
[Serializable]
public delegate AudioConverterError AudioConverterComplexInputData (ref int numberDataPackets, AudioBuffers data, ref AudioStreamPacketDescription[] dataPacketDescription);

New Type: MonoTouch.AudioToolbox.AudioConverterError

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[Serializable]
public enum AudioConverterError {
 None,
 FormatNotSupported,
 OperationNotSupported,
 PropertyNotSupported,
 InvalidInputSize,
 InvalidOutputSize,
 UnspecifiedError,
 BadPropertySizeError,
 RequiresPacketDescriptionsError,
 InputSampleRateOutOfRange,
 OutputSampleRateOutOfRange,
 HardwareInUse,
 NoHardwarePermission
}

New Type: MonoTouch.AudioToolbox.AudioConverterPrimeInfo

1
2
3
4
5
6
public struct AudioConverterPrimeInfo {
 
 public int LeadingFrames;
 public int TrailingFrames;
}

New Type: MonoTouch.AudioToolbox.AudioConverterPrimeMethod

1
2
3
4
5
6
7
[Serializable]
public enum AudioConverterPrimeMethod {
 Pre,
 Normal,
 None
}

New Type: MonoTouch.AudioToolbox.AudioConverterQuality

1
2
3
4
5
6
7
8
9
[Serializable]
public enum AudioConverterQuality {
 Max,
 High,
 Medium,
 Low,
 Min
}

New Type: MonoTouch.AudioToolbox.AudioConverterSampleRateConverterComplexity

1
2
3
4
5
6
7
[Serializable]
public enum AudioConverterSampleRateConverterComplexity {
 Linear,
 Normal,
 Mastering
}

Type Changed: MonoTouch.AudioToolbox.AudioFile

Removed:
1
2
3
4
  public int WritePackets (bool useCache, long inStartingPacket, AudioStreamPacketDescription[] inPacketDescriptions, IntPtr buffer, int count);
  public int WritePackets (bool useCache, long inStartingPacket, AudioStreamPacketDescription[] inPacketDescriptions, IntPtr buffer, int count, out int errorCode);
  public int WritePackets (bool useCache, long inStartingPacket, int numPackets, IntPtr buffer, int count);
Added:
1
2
3
4
5
6
7
8
  public bool IsPropertyWritable (AudioFileProperty property);
  public AudioFileError ReadPackets (bool useCache, out int numBytes, AudioStreamPacketDescription[] packetDescriptions, long startingPacket, ref int numPackets, IntPtr buffer);
  public AudioFileError WritePackets (bool useCache, int numBytes, AudioStreamPacketDescription[] packetDescriptions, long startingPacket, ref int numPackets, IntPtr buffer);
  public int WritePackets (bool useCache, long startingPacket, AudioStreamPacketDescription[] packetDescriptions, IntPtr buffer, int count);
  public int WritePackets (bool useCache, long startingPacket, AudioStreamPacketDescription[] packetDescriptions, IntPtr buffer, int count, out int errorCode);
  public int WritePackets (bool useCache, long startingPacket, int numPackets, IntPtr buffer, int count);
   set;

New Type: MonoTouch.AudioToolbox.AudioFileError

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[Serializable]
public enum AudioFileError {
 Unspecified,
 UnsupportedFileType,
 UnsupportedDataFormat,
 UnsupportedProperty,
 BadPropertySize,
 Permissions,
 NotOptimized,
 InvalidChunk,
 DoesNotAllow64BitDataSize,
 InvalidPacketOffset,
 InvalidFile,
 FileNotOpen,
 EndOfFile,
 FileNotFound,
 FilePosition
}

Type Changed: MonoTouch.AudioToolbox.AudioSession

Added:
1
2
  public event EventHandler<AudioSessionRouteChangeEventArgs> AudioRouteChanged;

New Type: MonoTouch.AudioToolbox.AudioSessionRouteChangeEventArgs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class AudioSessionRouteChangeEventArgs : EventArgs {
 
 public AudioSessionRouteChangeEventArgs (IntPtr dictHandle);
 
 public AudioSessionInputRouteKind CurrentInputRoute {
  get;
 }
 public AudioSessionOutputRouteKind[] CurrentOutputRoutes {
  get;
 }
 public MonoTouch.Foundation.NSDictionary Dictionary {
  get;
 }
 public AudioSessionInputRouteKind PreviousInputRoute {
  get;
 }
 public AudioSessionOutputRouteKind[] PreviousOutputRoutes {
  get;
 }
 public AudioSessionRouteChangeReason Reason {
  get;
 }
}

Namespace: MonoTouch.AudioUnit

Type Changed: MonoTouch.AudioUnit.AudioComponentDescription

Removed:
1
2
  public int ComponentFlags;
Added:
1
2
  public AudioComponentFlag ComponentFlags;

New Type: MonoTouch.AudioUnit.AudioComponentFlag

1
2
3
4
5
6
[Serializable]
[Flags]
public enum AudioComponentFlag {
 Unsearchable
}

Type Changed: MonoTouch.AudioUnit.ExtAudioFile

Added:
1
2
3
4
5
  public ExtAudioFileError SynchronizeAudioConverter ();
  public MonoTouch.AudioToolbox.AudioConverter AudioConverter {
   get;
  }

Namespace: MonoTouch.AudioUnitWrapper

Type Changed: MonoTouch.AudioUnitWrapper._AudioConverter

Removed:
1
2
 public class _AudioConverter : IDisposable {
Added:
1
2
3
 [Obsolete]
public class _AudioConverter : IDisposable {

Type Changed: MonoTouch.AudioUnitWrapper._AudioConverterEventArgs

Removed:
1
2
 public class _AudioConverterEventArgs : EventArgs {
Added:
1
2
3
 [Obsolete]
public class _AudioConverterEventArgs : EventArgs {

Namespace: MonoTouch.CoreAnimation

Type Changed: MonoTouch.CoreAnimation.CAEmitterCell

Removed:
1
2
  public virtual MonoTouch.CoreGraphics.CGImage Contents {
Added:
1
2
  public MonoTouch.CoreGraphics.CGImage Contents {

Namespace: MonoTouch.CoreData

Type Changed: MonoTouch.CoreData.NSAttributeDescription

Removed:
1
2
  public virtual void SetDefaultValue (MonoTouch.Foundation.NSObject value);
Added:
1
2
3
  [Obsolete("Use the DefaultValue property")]
 public virtual void SetDefaultValue (MonoTouch.Foundation.NSObject value);

Type Changed: MonoTouch.CoreData.NSManagedObjectModel

Removed:
1
2
3
4
  public virtual IntPtr Init {
   get;
  }

Namespace: MonoTouch.CoreLocation

Type Changed: MonoTouch.CoreLocation.CLLocationManager

Removed:
1
2
  public event EventHandler DidStartMonitoringForRegion;
Added:
1
2
  public event EventHandler<CLRegionEventArgs> DidStartMonitoringForRegion;

Type Changed: MonoTouch.CoreLocation.CLLocationManagerDelegate

Removed:
1
2
  public virtual void DidStartMonitoringForRegion (CLRegion region);
Added:
1
2
3
4
  public virtual void DidStartMonitoringForRegion (CLLocationManager manager, CLRegion region);
  [Obsolete("Do not override this method, override the (CLLocationManager, CLRegion) overload instead.")]
 public virtual void DidStartMonitoringForRegion (CLRegion region);

Namespace: MonoTouch.Foundation

Type Changed: MonoTouch.Foundation.NSCalendar

Added:
1
2
3
4
5
  public virtual NSDateComponents Components (NSCalendarUnit unitFlags, NSDate fromDate);
  public virtual NSDateComponents Components (NSCalendarUnit unitFlags, NSDate fromDate, NSDate toDate, NSDateComponentsWrappingBehavior opts);
  public virtual NSDate DateByAddingComponents (NSDateComponents comps, NSDate date, NSDateComponentsWrappingBehavior opts);
  public virtual NSDate DateFromComponents (NSDateComponents comps);

New Type: MonoTouch.Foundation.NSDateComponentsWrappingBehavior

1
2
3
4
5
6
[Serializable]
public enum NSDateComponentsWrappingBehavior {
 None,
 WrapCalendarComponents
}

New Type: MonoTouch.Foundation.NSFileHandle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
public class NSFileHandle : NSObject {
 
 public NSFileHandle (NSCoder coder);
 public NSFileHandle (NSObjectFlag t);
 public NSFileHandle (IntPtr handle);
 public NSFileHandle (int fd, bool closeOnDealloc);
 public NSFileHandle (int fd);
 
 public static NSFileHandle FromNullDevice ();
 public static NSFileHandle FromStandardError ();
 public static NSFileHandle FromStandardInput ();
 public static NSFileHandle FromStandardOutput ();
 public static NSFileHandle OpenRead (string path);
 public static NSFileHandle OpenReadUrl (NSUrl url, out NSError error);
 public static NSFileHandle OpenUpdate (string path);
 public static NSFileHandle OpenUpdateUrl (NSUrl url, out NSError error);
 public static NSFileHandle OpenWrite (string path);
 public static NSFileHandle OpenWriteUrl (NSUrl url, out NSError error);
 public virtual void AcceptConnectionInBackground ();
 public virtual void AcceptConnectionInBackground (NSString[] notifyRunLoopModes);
 public virtual NSData AvailableData ();
 public virtual void CloseFile ();
 public virtual ulong OffsetInFile ();
 public virtual NSData ReadDataOfLength (uint length);
 public virtual NSData ReadDataToEndOfFile ();
 public virtual void ReadInBackground ();
 public virtual void ReadInBackground (NSString[] notifyRunLoopModes);
 public virtual void ReadToEndOfFileInBackground ();
 public virtual void ReadToEndOfFileInBackground (NSString[] notifyRunLoopModes);
 public virtual ulong SeekToEndOfFile ();
 public virtual void SeekToFileOffset (ulong offset);
 public virtual void SetReadabilityHandler (NSFileHandleUpdateHandler readCallback);
 public virtual void SetWriteabilityHandle (NSFileHandleUpdateHandler writeCallback);
 public virtual void SynchronizeFile ();
 public virtual void TruncateFileAtOffset (ulong offset);
 public virtual void WaitForDataInBackground ();
 public virtual void WaitForDataInBackground (NSString[] notifyRunLoopModes);
 public virtual void WriteData (NSData data);
 
 public static NSString ConnectionAcceptedNotification {
  get;
 }
 public static NSString DataAvailableNotification {
  get;
 }
 public static NSString OperationException {
  get;
 }
 public static NSString ReadCompletionNotification {
  get;
 }
 public static NSString ReadToEndOfFileCompletionNotification {
  get;
 }
 public override IntPtr ClassHandle {
  get;
 }
 public virtual int FileDescriptor {
  get;
 }
 
 public static class Notifications {
  
  public static NSObject ObserveConnectionAccepted (EventHandler handler);
  public static NSObject ObserveDataAvailable (EventHandler handler);
  public static NSObject ObserveReadCompletion (EventHandler handler);
  public static NSObject ObserveReadToEndOfFileCompletion (EventHandler handler);
 }
}

New Type: MonoTouch.Foundation.NSFileHandleConnectionAcceptedEventArgs

1
2
3
4
5
6
7
8
9
10
11
12
public class NSFileHandleConnectionAcceptedEventArgs : NSNotificationEventArgs {
 
 public NSFileHandleConnectionAcceptedEventArgs (NSNotification notification);
 
 public NSFileHandle NearSocketConnection {
  get;
 }
 public int UnixErrorCode {
  get;
 }
}

New Type: MonoTouch.Foundation.NSFileHandleReadEventArgs

1
2
3
4
5
6
7
8
9
10
11
12
public class NSFileHandleReadEventArgs : NSNotificationEventArgs {
 
 public NSFileHandleReadEventArgs (NSNotification notification);
 
 public NSData AvailableData {
  get;
 }
 public int UnixErrorCode {
  get;
 }
}

New Type: MonoTouch.Foundation.NSFileHandleUpdateHandler

1
2
3
[Serializable]
public delegate void NSFileHandleUpdateHandler (NSFileHandle handle);

Type Changed: MonoTouch.Foundation.NSInputStream

Removed:
1
2
  public NSInputStream ();
Added:
1
2
  protected NSInputStream ();

Type Changed: MonoTouch.Foundation.NSObject

Added:
1
2
3
  public NSObject (IntPtr handle, bool alloced);
  public static void InvokeInBackground (NSAction action);

New Type: MonoTouch.Foundation.NSPipe

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class NSPipe : NSObject {
 
 public NSPipe ();
 public NSPipe (NSCoder coder);
 public NSPipe (NSObjectFlag t);
 public NSPipe (IntPtr handle);
 
 public static NSPipe Create ();
 protected override void Dispose (bool disposing);
 
 public override IntPtr ClassHandle {
  get;
 }
 public virtual NSFileHandle ReadHandle {
  get;
 }
 public virtual NSFileHandle WriteHandle {
  get;
 }
}

New Type: MonoTouch.Foundation.NSSearchPath

1
2
3
4
5
public static class NSSearchPath {
 
 public static string [] GetDirectories (NSSearchPathDirectory directory, NSSearchPathDomain domainMask, bool expandTilde);
}

Type Changed: MonoTouch.Foundation.NSUrlProtocol

Removed:
1
2
   set;

Namespace: MonoTouch.GameKit

Type Changed: MonoTouch.GameKit.GKScore

Removed:
1
2
3
4
5
  [Obsolete("Use Date property")]
 public virtual MonoTouch.Foundation.NSDate date {
   get;
  }

Namespace: MonoTouch.ObjCRuntime

Type Changed: MonoTouch.ObjCRuntime.Class

Added:
1
2
3
4
  public static IntPtr GetHandleIntrinsic (string name);
  
  public static bool ThrowOnInitFailure;

Type Changed: MonoTouch.ObjCRuntime.Messaging

Added:
1
2
3
4
5
6
  public static IntPtr IntPtr_objc_msgSend_int_bool (IntPtr receiver, IntPtr selector, int arg1, bool arg2);
  public static IntPtr IntPtr_objc_msgSend_int_IntPtr_IntPtr_int (IntPtr receiver, IntPtr selector, int arg1, IntPtr arg2, IntPtr arg3, int arg4);
  public static IntPtr IntPtr_objc_msgSendSuper_int_bool (IntPtr receiver, IntPtr selector, int arg1, bool arg2);
  public static IntPtr IntPtr_objc_msgSendSuper_int_IntPtr_IntPtr_int (IntPtr receiver, IntPtr selector, int arg1, IntPtr arg2, IntPtr arg3, int arg4);
  public static void void_objc_msgSend_intptr_intptr (IntPtr receiver, IntPtr selector, IntPtr arg1, IntPtr arg2);

Type Changed: MonoTouch.ObjCRuntime.Selector

Added:
1
2
  public bool Equals (Selector right);

Namespace: MonoTouch.Security

Type Changed: MonoTouch.Security.SecKey

Added:
1
2
3
4
  public SecKey (IntPtr handle);
  public SecKey (IntPtr handle, bool owns);
  

Namespace: MonoTouch.UIKit

Type Changed: MonoTouch.UIKit.UIApplication

Removed:
1
2
  public virtual void SetStatusBarHidden (bool hiddent, bool animated);
Added:
1
2
3
4
5
6
7
8
  public virtual void SetStatusBarHidden (bool hidden, bool animated);
  public static MonoTouch.Foundation.NSString StateRestorationBundleVersionKey {
   get;
  }
  public static MonoTouch.Foundation.NSString StateRestorationUserInterfaceIdiomKey {
   get;
  }

Type Changed: MonoTouch.UIKit.UIImage

Removed:
1
2
  public UIImage (UIEdgeInsets capInsets, UIImageResizingMode resizingMode);
Added:
1
2
  public virtual UIImage CreateResizableImage (UIEdgeInsets capInsets, UIImageResizingMode resizingMode);

New Type: MonoTouch.UIKit.UILocalizedIndexedCollation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class UILocalizedIndexedCollation : MonoTouch.Foundation.NSObject {
 
 public UILocalizedIndexedCollation ();
 public UILocalizedIndexedCollation (MonoTouch.Foundation.NSCoder coder);
 public UILocalizedIndexedCollation (MonoTouch.Foundation.NSObjectFlag t);
 public UILocalizedIndexedCollation (IntPtr handle);
 
 public static UILocalizedIndexedCollation CurrentCollation ();
 public virtual int GetSectionForObject (MonoTouch.Foundation.NSObject obj, MonoTouch.ObjCRuntime.Selector collationStringSelector);
 public virtual int GetSectionForSectionIndexTitle (int indexTitleIndex);
 public virtual MonoTouch.Foundation.NSObject[] SortedArrayFromArraycollationStringSelector (MonoTouch.Foundation.NSObject[] array, MonoTouch.ObjCRuntime.Selector collationStringSelector);
 
 public override IntPtr ClassHandle {
  get;
 }
 public virtual string [] SectionIndexTitles {
  get;
 }
 public virtual string [] SectionTitles {
  get;
 }
}

New Type: MonoTouch.UIKit.UIStateRestoration

1
2
3
4
5
6
7
public static class UIStateRestoration {
 
 public static MonoTouch.Foundation.NSString ViewControllerStoryboardKey {
  get;
 }
}

Tuesday, July 29, 2014

Xamarin Basics iOS -Button Click


Steps
1. You have to add button on UI (xib from xcode)
2.Create outlet for button (In xcode itself)
3.Go to corresponding .cs class (In Xamarin Studio)
4.Write the following code

btnName.Activated+=(Object sender,EventArgs e )=>{
               // You can write the code here,that you want to perform in button click
            };



Friday, July 25, 2014

Modern Objective c



Use 'Modern Objective-C Syntax'

Objective-C makes heavy use of the @ operator, which generally denotes Objective-C objects. For example, "string" is a char*, while @"string" is an NSString. These have been standard in Objective-C for a long time, but only recently, in Objective-C 2.0, did Apple add in definitions for NSDictionary, NSArray, and NSNumber, all using literals specified with @ directives.

-----------------------------------------------------------------------------------------------------
NSNumber *number = [NSNumber numberWithInteger:7];
NSNumber *modernNumber = @(7); // or @7
-----------------------------------------------------------------------------------------------------
NSArray *array = [NSArray arrayWithObjects:number, modernNumber, nil];
NSArray *modernArray = @[number, modernNumber];
-----------------------------------------------------------------------------------------------------
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:number, @"number"];
NSDictionary *modernDictionary = @{@"number" : number};
-----------------------------------------------------------------------------------------------------


It's more concise, and still somehow more readable.


Enum 

Replace your enum declarations, such as this one:
enum {

        UITableViewCellStyleDefault,

        UITableViewCellStyleValue1,

        UITableViewCellStyleValue2,

        UITableViewCellStyleSubtitle

};

typedef NSInteger UITableViewCellStyle;


with the NS_ENUM syntax:



typedef NS_ENUM(NSInteger, UITableViewCellStyle) {

        UITableViewCellStyleDefault,

        UITableViewCellStyleValue1,

        UITableViewCellStyleValue2,

        UITableViewCellStyleSubtitle

};


But when you use enum to define a bitmask, such as here:

enum {

        UIViewAutoresizingNone                 = 0,

        UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,

        UIViewAutoresizingFlexibleWidth        = 1 << 1,

        UIViewAutoresizingFlexibleRightMargin  = 1 << 2,

        UIViewAutoresizingFlexibleTopMargin    = 1 << 3,

        UIViewAutoresizingFlexibleHeight       = 1 << 4,

        UIViewAutoresizingFlexibleBottomMargin = 1 << 5

};
typedef NSUInteger UIViewAutoresizing;

use the NS_OPTIONS macro.


typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {

        UIViewAutoresizingNone                 = 0,

        UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,

        UIViewAutoresizingFlexibleWidth        = 1 << 1,

        UIViewAutoresizingFlexibleRightMargin  = 1 << 2,

        UIViewAutoresizingFlexibleTopMargin    = 1 << 3,

        UIViewAutoresizingFlexibleHeight       = 1 << 4,

        UIViewAutoresizingFlexibleBottomMargin = 1 << 5

};

Alternatively, you can use the modern Objective-C converter in Xcode to make this change to your code automatically. 

Thursday, June 19, 2014

iOS -Swift Basics

The Basics
Swift does away with the standard of declaring variables by starting with their type names, and instead opts to use a Javascript-like ‘var’ keyword to define any variable.
So for instance in Objective-C where you have this:
NSString *myString = @"This is my string.";
You now have this:
var myString = "This is my string."
Meanwhile constants are expressed with the ‘let’ keyword
let kSomeConstant = 40
In this case kSomeConstant is implicitly defined as an integer. If you want to be more specific you can specify which type it is like so:
let kSomeConstant: Int = 40
With both arrays and dictionaries, they are described using brackets []
var colorsArray = ["Blue", "Red", "Green", "Yellow"]
var colorsDictionary = ["PrimaryColor":"Green", "SecondaryColor":"Red"]

Monday, June 2, 2014

Apple talks iOS 8

Quick Reply: iOS 8 features the ability to quickly respond to messages from Notification Center as well as the lock screen

Favorite Contacts in Multitasking: Favorite contacts are now available in the multitasking view

Safari for iPad has new tabs view: The same tabs view from Safari on iPhone is now available on iPad as well as OS X Yosemite’s sidebar

Quick reply for third party apps: This includes apps like Facebook

Mail gestures and management improvements: Similar to Mailbox, gesture based actions and deeper integration with Calendar and better multitasking within Mail

Spotlight: Spotlight now has more advanced features on iOS similar to OS X Yosemite including in-line results from Wikipedia and music on iTunes. Spotlight is also built-in to Safari’s search field as an alternative to Google Search

Quicktype: iOS 8 features a keyboard feature called Quicktype which is an alternative keyboard with suggestive typing with context awareness. Typing learning is private to the device so not shared or accessible by others; securely implemented.

Continuity: Same continuity features demoed under Yosemite.

Messages: Support for naming threads and group message management. This includes Do Not Disturb support per thread and the ability to leave the thread. Sharing is also made easier with the iOS 8 version of Messages including attachment management and voice, photo, and video sharing. Location sharing is also made much easier.
Messaging is very similar to Facebook’s Messenger app in terms of sharing photos and videos quickly as well as voice. Audio and video messages are allowed to delete after a period of time to avoid large files clogging up storage similar to Snapchat and other message apps. Audio messages can be heard from the lock screen using a Raise to Hear feature.

iCloud Drive: iCloud Drive allows users to work with documents across applications on iOS 8 using documents stored in iCloud.

Enterprise: iOS 8 includes a new enrollment program making enterprise device usage much easier.
HealthKit & Health: HealthKit is a feature that speaks with fitness and health apps to pull information from various apps into a single app called Health that centralizes results. The software features integration with the Mayo Clinic. It can present weight, activity, heart rate, and more.

Family Sharing: This feature brings together family photo streams, calendars, reminders, Find My Friends, and even shared purchases up to six family members on iTunes, App Store, and iBooks. This is connected by the credit card.

Photos: iCloud now stores all photos including more than what can fit on the device. Photos also includes advanced search features now with perimeters like time, location, and albums.
Photos also now features advanced editing features within the app. Photos and videos are backed up to iCloud at full resolution, but requires iCloud storage space. New pricing and storage tiers will be available.

Shazam: Siri will support Shazam for music recognition in iOS 8 as well as feature a hands-free mode with the Hey Siri command.

Availability: iOS 8 will be available in beta today for developers and publicly this fall.

Apple Launches Swift, A New Programming Language For Writing iOS And OS X Apps

At its WWDC developer event today, Apple surprised all of the developers in the audience by launching a new programming language called Swift. This new language seems to be poised to replace Objective-C as the main programming language on Apple’s platforms.
Swift will use the same LLVM compiler and runtime as Apple’s Objective-C implementation, so Swift and Objective-C code can live side-by-side in the same application. The language provides access to all of the Cocoa and Cocoa Touch features developers are currently used to from Objective-C.
It should feel familiar to those who are already used to Objective-C, Apple says, and is meant to “unify the procedural and object-oriented portions of the language.” It does diverge from Objective-C in more than just the syntax, though; it also features variable types like tuples and optional types. It also includes operators that aren’t found in Objective-C, which allow you to perform remainder operations on floating-point numbers, for example.
Here are some of the highlights of the language according to Apple:
  • Closures (similar to blocks in C and Objective-C) unified with function pointers
  • Tuples and multiple return values
  • Generics
  • Fast and concise iteration over a range or collection
  • Structs that support methods, extensions, protocols.
  • Functional programming patterns, e.g.: map and filter
In addition, Apple notes how the language was designed for safety, with variables that have to be initialized before use, arrays and integers that are checked for overflow and automatic memory management.
Swift support, of course, will be deeply integrated into Apple’s updated Xcode IDE. It will feature an interactive “Playground” that allows you to edit your code and watch how your changes influence your app in real-time. Xcode’s debugging console now also supports Swift syntax natively.
IMG_0258
According to Apple, Swift will provide a number of significant speed advantages to developers. A complex object sort, for example, will run 3.9x faster than an implementation of the same algorithm in Python. That’s also faster than Objective-C, which is 2.8x faster than the Python version.
IMG_0254
We will obviously need to take a closer look at this new programming language and how it relates to other languages. Apple is making the documentation available today, both as an iBook and on its developer site.
Objective-C was always a hard language to pick up for new developers. We will also have to see if Swift makes getting started with app development on Apple’s platforms easier, but from a first look at the documentation, it definitely feels more accessible than Objective-C.
IMG_0266