Skip to content

Instantly share code, notes, and snippets.

View randhirraj3130's full-sized avatar

Randhir Raj randhirraj3130

View GitHub Profile
@randhirraj3130
randhirraj3130 / CardView.h
Created June 29, 2018 10:21
How to create card view in swift and objective c
#import <UIKit/UIKit.h>
@interface CardView : UIView
@end
@randhirraj3130
randhirraj3130 / setGetModelData
Created June 29, 2018 10:12
How to set and get data from model class
// set data be like this
var dataList = [Any]()
for items in DataArray
{
let data = RunnningJobModel.initWithDictionary(dictionary: items as! NSDictionary)
self.dataList.append(data)
}
@randhirraj3130
randhirraj3130 / GetData.swift
Created April 18, 2018 12:49
How to get and post data using Alamofire
// GET the JSON Data like this
Alamofire.request("YOUR-SERVER-URL").responseJSON { response in
print("Request: \(String(describing: response.request))") // original url request
print("Response: \(String(describing: response.response))") // http url response
print("Result: \(response.result)")// response serialization resul
if let json = response.result.value{
let JsonData = json as! NSDictionary
let status = JsonData["status"] as? Int
let message = JsonData["message"] as? String
@randhirraj3130
randhirraj3130 / ValidateEmail.cs
Created August 2, 2017 07:09
how to validate email in unity c#
step 1-import the following
using System.Text.RegularExpressions;
step 2- define
public const string MatchEmailPattern =
@"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
+ @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
+ @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
+ @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";
step 3-call the following function
@randhirraj3130
randhirraj3130 / SimpleJSON.cs
Created July 12, 2017 12:38
how to send data on server in unity c#
//#define USE_SharpZipLib
#if !UNITY_WEBPLAYER
#define USE_FileIO
#endif
/* * * * *
* A simple JSON Parser / builder
* ------------------------------
*
* It mainly has been written as a simple JSON parser. It can build a JSON string
@randhirraj3130
randhirraj3130 / TwitterLogin.m
Created June 21, 2017 08:18
twitter login in objective-c
//follow to following steps to get twitter login
step1- register your app on twitter dashboard
step 2- add following code in info.plist betbeen <dict> and </dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-<consumerKey></string>
@randhirraj3130
randhirraj3130 / showToast.cs
Created June 6, 2017 06:11
how to show the toast the in unity for android devices
public static void showToast(string text)
{
if (Application.platform == RuntimePlatform.Android) {
AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity");
AndroidJavaClass Toast = new AndroidJavaClass ("android.widget.Toast");
AndroidJavaObject javaString = new AndroidJavaObject ("java.lang.String", text);
AndroidJavaObject context = currentActivity.Call<AndroidJavaObject> ("getApplicationContext");
AndroidJavaObject toast = Toast.CallStatic<AndroidJavaObject> ("makeText", context, javaString, Toast.GetStatic<int> ("LENGTH_SHORT"));
@randhirraj3130
randhirraj3130 / callwebservice.swift
Last active November 7, 2017 14:30
how to send data on server in ios
func sendData()
{
let old_price = Price.text!
UserDefaults.standard.setValue(old_price, forKey: "old_price")
let prs = [
"coupon_code": CoupanField.text! as String ,
"order_price" : "\(final_price)"
] as [String:String]
Service.Start(VC: self,dic: prs, url: "\(GlobalVariable.serverName)coupon.php", onCompletion: { result in
print("result \(result)")
@randhirraj3130
randhirraj3130 / webService.m
Created April 7, 2017 06:54
how to send data from server in objective c
-(void)sendData:(NSString*)email : (NSString*)password :(NSString*)user_id : (NSString*)urlString : (NSString*)name {
NSLog(@"sendData");
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url];
NSString *dataString = [NSString stringWithFormat:@"email=%@&password=%@&id=%@",email,password,user_id];
NSData *requestData = [dataString dataUsingEncoding:NSUTF8StringEncoding];
@randhirraj3130
randhirraj3130 / instagramLogin.swift
Created April 5, 2017 06:37
instagram login in swift 3
// add the webview to your view controller add call web view delegate
// register your app into instagram
// add following code in to button action
let clientID = "aef611af2a1e4806a7de8c0aca13daac"
let redirect_uri = "http://weebook.in/"
let getAccessToken = "https://api.instagram.com/oauth/authorize/?client_id=\(clientID)&redirect_uri=\(redirect_uri)&response_type=token"
self.InstagramWebView.loadRequest(NSURLRequest(url: NSURL(string:getAccessToken as String)! as URL) as URLRequest)
// delegate function of weview