Showing posts with label Objc. Show all posts
Showing posts with label Objc. Show all posts

Sunday, January 1, 2017

Getting Started with React Native

Brew Update

$brew update
$brew install node
$brew install watchman
$brew install yarn

$npm install -g react-native-cli

Init Project

$react-native init MyProject
$cd MyProject
$react-native run-ios

This will open up the Simulator but you can always open up Xcode manually
and show some fancy terminal window saying running on part 8081 blaa blaa 



Native means Xcode

$cd ios

$open MyProject.xcodeproj

Run the project and you might see following all over the debugger window !!!

 __nw_connection_get_connected_socket_block_invoke 50 Connection has no connected handler

  1. Xcode menu -> Product -> Edit Scheme...
  2. Environment Variables -> Add -> Name: "OS_ACTIVITY_MODE", Value:"disable"
  3. Run your again


If every thing goes well you can run the project which shows the following screen.


Hello World!

"Welcome to React Native!" ... Seriously ? 
Some thing is very wrong about this window where is "Hello World!"

If you open the project folder you will see the following folder structure - 


You can open the index.ios.js file on any text editor of your choice, but as we are making a native app lets open it in Xcode itself ! 

Drag and drop the file in Currently open Xcode project but make sure you uncheck both 
 - Copy Items if needed  &
-  Add to target


Now open the file and navigate to line sweet 16 ! 
render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
            Hello World!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+D or shake for dev menu
        </Text>
      </View>
    );
  }

Just replace the Line 20 with Hello World!

Now you do NOT need to hit "Cmd+R" on Xcode, just open the Simulator and hit "Cmd+R"
and with just small flicker for microsecond what you see is new content ! 
WoW !!! Thats the beauty of React Native - No compiling of code just reloading the view.

Note - don’t close the Terminal window; just keep it running in the background. If you do close it by mistake, simply stop and re-run the project via Xcode.

Links - 





Friday, September 11, 2015

Swift 2.0 Strings


After functional coding I feel the biggest change from Obj-C world to Swift was in support of Unicode string.

Then again the huge change from Swift 1.2 to Swift 2.0 might be in String.
In someway its a dramatic change !
As stated in Swift Blog

Swift provides a performant, Unicode-compliant string implementation as part of its Standard Library. In Swift 2, theString type no longer conforms to the CollectionType protocol, where String was previously a collection of Character values, similar to an array. Now, String provides a characters property that exposes a character collection view.


var letters: [Character] = ["c", "a", "f", "e"]
var string: String = String(letters)

print(letters.count) // 4
print(string) // cafe
print(string.characters.count) // 4


let acuteAccent: Character = "\u{0301}" // ´ COMBINING ACUTE ACCENT' (U+0301)

string.append(acuteAccent)
print(string.characters.count) // 4
print(string.characters.last!) // é



https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html


NOTE
Extended grapheme clusters can be composed of one or more Unicode scalars. This means that different characters—and different representations of the same character—can require different amounts of memory to store. Because of this, characters in Swift do not each take up the same amount of memory within a string’s representation. As a result, the number of characters in a string cannot be calculated without iterating through the string to determine its extended grapheme cluster boundaries. If you are working with particularly long string values, be aware that the count(_:) function must iterate over the Unicode scalars in the entire string in order to calculate an accurate character count for that string.


The character count returned by the count(_:) function is not always the same as the length property of an NSString that contains the same characters. The length of an NSString is based on the number of 16-bit code units within the string’s UTF-16 rpresentation and not the number of Unicode extended grapheme clusters within the string. To reflect this fact, the length property from NSString is called utf16Count when it is accessed on a Swift String value.

Reference - 

Tuesday, July 28, 2015

TestFlight Beta Testing Guidelines


TestFlight Beta Testing Guidelines


1. First thing to note is that test flight approval does not mean final iTunes app approval. 
2. The time Apple takes to review test flight build is only 1-2 business days where as an App store approval ranges from 5-15 business days. Normally its 6 days but during new product lunch iPhone / iPad ( mid Sep & Oct ) and  launch or especial event like WWDC ( Jun )  or during holidays ( Dec ) the time can increase as store even remain close for some time. 
3. The distribution of iOS app is done via TestFlight. It is the app available in iOS App store from Apple, which will help user get latest TestFlight Builds. 
  • Distribute prerelease builds of your app to testers to collect feedback and prepare your app for release in the App Store.
  • TestFlight beta testing in iTunes Connect is available only for iOS apps.
  •  You can enable TestFlight beta testing for up to 10 apps at one time in your developer account.
  •  Distribute the app to internal testers. 
  • Submit the app for Beta App Review, and distribute it to External users.
  • The build will be available to them for 30 days after the invitations are sent.

Difference Between Internal Testers and External User 
Internal test
  • Does not require App approval from apple.
  • You are not required to supply all metadata in order to invite internal testers to test a prerelease build of your app.
  • You can enable up to 25 users from your iTunes Connect team to be internal testers 
  • To be eligible to become an internal tester, a user must be part of your iTunes Connect team with the Admin, Legal, or Technical role. Adding iTunes Connect users and setting their roles. 
External test
  • You can enable up to 1000 users to be external testers per app.
  • External testers do not need to be in your organization; you can invite any user with an email address to become one of your external testers.
  • You’ll need an email address for each tester and optionally their first and last names. 
  • Your app must pass Beta App Review before you can invite your external testers to test it 
  • To enable external users to test a prerelease build of your app, you must supply the following metadata
    • What to test
    • App description
    • Feedback email
    • Marketing URL
    • Support URL
    • Privacy policy URL (optional)
    • Beta App Review contact information
    • Beta App Review notes (optional)

Submit to the App Store
When you are done using TestFlight beta testing, you can submit the app for final review. Before you submit it, make sure you no longer want to test it or any builds you uploaded earlier than it. When the app becomes Ready for Sale in the App Store, testing automatically stops on earlier builds, and you will be unable to view or test them.
If you want to resume testing of an earlier build, you can upload it as a new build associated with a new prerelease version.
Link - 

Monday, May 11, 2015

iOS SideMenu / SideDrawer / SlidingView - Best Frameworks - GitHub Links


Top 5 iOS ( Objective-C ) Side Menu Frameworks are -

MMDrawerController

A lightweight, easy to use, Side Drawer Navigation Controller
https://github.com/mutualmobile/MMDrawerController


SWRevealViewController

A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right !
https://github.com/John-Lluch/SWRevealViewController


MSDynamicsDrawerViewController

Container view controller that leverages UIKit Dynamics to provide a realistic drawer navigation paradigm.

https://github.com/erichoracek/MSDynamicsDrawerViewController


ECSlidingViewController

Customizable sliding view controller container.

https://github.com/ECSlidingViewController/ECSlidingViewController


PPRevealSideViewController

A new container controller to easily push views on side like Path or Facebook

https://github.com/ipup/PPRevealSideViewController

Tuesday, April 7, 2015

Objective-C REST API Network Status Codes

Objective-C REST API Network Status Codes 

/*!
@typedef NS_ENUM (NSUInteger, kStatusInformation)
@abstract Informational responses.
@discussion
These are valid only in the scope of <Project Name>.
*/
typedef NS_ENUM(NSInteger, kStatusInformation) {
/*!
This interim response indicates that everything so far is OK
and that the client should continue with the request or ignore
it if it is already finished.
*/
kStatusInformation_Continue = 100,
/*!
This code is sent in response to an Upgrade: request header by
the client, and indicates that the protocol the server is switching too.
It was introduced to allow migration to an incompatible protocol version,
and is not in common use.
*/
kStatusInformation_SwitchingProtocol = 101,
};
 
 
/*!
@typedef NS_ENUM (NSUInteger, kStatusSuccess)
@abstract Successful responses.
@discussion
These are valid only in the scope of Momentage.
*/
typedef NS_ENUM(NSInteger, kStatusSuccess) {
/*! The request has succeeded. */
kStatusSuccess_OK = 200,
/*!
The request has succeeded and a new resource has been
created as a result of it.
This is typically the response sent after a PUT request.
*/
kStatusSuccess_Created = 201,
/*!
The request has been received but not yet acted upon.
It is non-committal, meaning that there is no way in HTTP to later send
an asynchronous response indicating the outcome of processing the request.
It is intended for cases where another process or server handles the request,
or for batch processing.
*/
kStatusSuccess_Accepted = 202,
/*!
This response code means returned meta-information set is not exact
set as available from the origin server, but collected from a local
or a third party copy. Except this condition, 200 OK response should
be preferred instead of this response.
*/
kStatusSuccess_PartialInfo = 203,
/*!
There is no content to send for this request, but the headers may be
useful. The user-agent may update its cached headers for this
resource with the new ones.
*/
kStatusSuccess_NoResponse = 204,
/*!
This response code is sent after accomplishing request to tell user
agent reset document view which sent this request.
*/
kStatusSuccess_RestContent = 205,
/*!
This response code is used because of range header sent by the client
to separate download into multiple streams.
*/
kStatusSuccess_PartialContent = 206,
/*! */
kStatusSuccess_251 = 251,
};
/*! */
 
/*!
@typedef NS_ENUM (NSUInteger, FBErrorCode)
@abstract Error codes returned by the Facebook SDK in NSError.
@discussion
These are valid only in the scope of FacebookSDKDomain.
*/
typedef NS_ENUM(NSInteger, APIErrorCode) {
APIErrorCodeMultipleChoice = 300
};
 
 
// 4xx Client error
/*!
@typedef NS_ENUM (NSUInteger, kStatusClientError)
@abstract Client error responses
@discussion
These are valid only in the scope of Momentage.
*/
typedef NS_ENUM(NSInteger, kStatusClientError) {
/*! */
kStatusClientError_BadRequest = 400,
/*! */
kStatusClientError_Unauthorized = 401,
/*! */
kStatusClientError_PaymentRequest = 402,
/*! */
kStatusClientError_Forbidden = 403,
/*! */
kStatusClientError_NotFound = 404,
/*! */
kStatusClientError_MethodNotAllowed = 405,
kStatusClientError_ExpectationFailed = 417,
};
 
// 5xx Server error responses
/*!
@typedef NS_ENUM (NSUInteger, kStatusServerError)
@abstract Client error responses
@discussion
These are valid only in the scope of Momentage.
*/
typedef NS_ENUM(NSInteger, kStatusServerError) {
/*! The server has encountered a situation it doesn't know how to handle. */
kStatusServerError_InternalError = 500,
/*!
The request method is not supported by the server and cannot be handled. The only
methods that servers are required to support (and therefore that must not return
this code) are GET and HEAD.
*/
kStatusServerError_NotImplemented = 501,
/*!
This error response means that the server, while working as a gateway to get a
response needed to handle the request, got an invalid response.
*/
kStatusServerError_BadGateway = 502,
/*!
The server is not ready to handle the request. Common causes are a server that is
down for maintenance or that is overloaded. Note that together with this response,
a user-friendly page explaining the problem should be sent. This responses should
be used for temporary conditions and the Retry-After: HTTP header should, if
possible, contain the estimated time before the recovery of the service. The
webmaster must also take care about the caching-related headers that are sent
along with this response, as these temporary condition responses should usually
not be cached.
*/
kStatusServerError_ServiceUnavailable = 503,
/*!
This error response is given when the server is acting as a gateway and cannot get
a response in time.
*/
kStatusServerError_GatewayTimeout = 504,
/*! The HTTP version used in the request is not supported by the server. */
kStatusServerError_HTTPVersionNotSupported = 505,
};

via - 
Github Gist

Other Links -