Aes encryption

Posted on 29 Haziran 2018 in Programlama by

iOS check update

Posted on 26 Haziran 2018 in Programlama by

Following is a swift code to check if update available.

    let plistUrl = ""
    let installationUrl = "itms-services://?action=download-manifest&url="
    func checkForUpdates() {
        DispatchQueue.main.async(execute: {
            if let url = URL(string: self.plistUrl), let updateDictionary = NSDictionary(contentsOf: url) {
                let items = updateDictionary["items"]
                let itemDict = (items as AnyObject).lastObject as! NSDictionary
                let metaData = itemDict["metadata"] as! NSDictionary
                let serverVersion = metaData["bundle-version"] as! String
                let localVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
                let updateAvailable =, options: NSString.CompareOptions.numeric) == .orderedDescending;

                if updateAvailable {
                    self.showUpdateDialog(serverVersion: serverVersion)
    func showUpdateDialog(serverVersion: String) {
        let alertController = UIAlertController(title: "New version of MSP available", message:
            "MSP \(serverVersion) has been released. Would you like to download it now?", preferredStyle: UIAlertControllerStyle.alert)
        alertController.addAction(UIAlertAction(title: "Not now", style: .cancel,handler: self.updateHandler))
        alertController.addAction(UIAlertAction(title: "Update", style: .default, handler: self.updateHandler))
        self.present(alertController, animated: true, completion: nil)

    func updateHandler(alert: UIAlertAction){
        switch alert.title {
        case "Update"?:
            UIApplication.shared.openURL(URL(string: self.installationUrl)!)
        case "Not now"?: break
        default: break

git quick start guide

Posted on 14 Haziran 2018 in Programlama by

This tutorial guides starting git in a clear way:

IOS Notes

Posted on 17 Mayıs 2018 in Programlama by

To call a function when application becomes active

NotificationCenter.default.addObserver(self, selector: #selector(didBecomeActive), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)

@objc func didBecomeActive() {
print(“did become active”)
//Do signaling offline works



Creation of temporary url path:

let destURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(“manifest.plist”)

Printing content of url

let contents = try String(contentsOf: destURL)

print(“!! contents:\(contents)”)

Must read iOS articles

Posted on 11 Mayıs 2018 in Programlama by

Debugging with xcode-8

Intermediate Debugging with Xcode 8

You can find pdf version of the page below
Intermediate Debugging with Xcode 8

Adaptive layout tutorial

Adaptive Layout Tutorial in iOS 11: Getting Started

You can find pdf version of the page and necessary attachments below
Adaptive Layout Tutorial in iOS 11: Getting Started
xcode project

IOS Visual format language–cms-22715

You can find pdf version of the page below

Introduction to the Visual Format Language

Real-Time Communication with Streams Tutorial for iOS

Sending firebase requests over rest client

Posted on 08 Mayıs 2018 in Programlama by

First of all a rest client should be installed to pc. You may use “advanced rest client” extension for chrome browser for its simplicity or postman.

Following headers should be added:

Content-Type application/json
Authorization key=your server key or legacy key

Fcm uses following url to accept http queries:

And at this point header configuration ui should be like similar to one below:

Server key could be obtained from firebase console page. It is located at “project settings”>>”cloud messaging” path. Following screenshot is added for illustration:

Continue reading…

Updating ios package on safari

Posted on 28 Mart 2018 in Programlama by

Just define a url as follows:

<a class=” btn-primary btn-lghref=”itms-services://?action=download-manifest&url=“>Download App</a>

and manifest.plist file should look like as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

As you can see ipa file path is defined in manifest file.

Java classpath usage

Posted on 20 Kasım 2016 in Programlama by

We will create following classes:

Create a class with package name as p1.p2.p3 at firstClass directory

package p1.p2.p3;
public class abc {
    public void printName(String name) {
        System.out.println("your name is "+name);

and compile it using following command:
javac -d .

lets add another class that uses abc class at secondClass directory

public class xyz extends{
    public static void main(String prm[]) {
        System.out.println("xyz class");
        tt deneme = new tt();

and following command is used to compile it:
javac -classpath ../firstClass/

To execute compiled binary use following command:
java -cp .:../firstClass xyz

callgraph generator

Posted on 14 Temmuz 2016 in Programlama by

sudo apt-get install -y kcachegrind valgrind
gcc main.c
valgrind --tool=callgrind ./a.out
# Generates a callgrind.out.<PID> file.
kcachegrind callgrind.out.1234
# Opens a GUI to visualize callgrind data.

auto_ptr and reference counting

Posted on 16 Ekim 2015 in Programlama by


A smart pointer is a class that wraps a ‘raw’ (or ‘bare’) C++ pointer, to manage the lifetime of the object being pointed to. There is no single smart pointer type, but all of them try to abstract a raw pointer in a practical way.

Smart pointers should be preferred over raw pointers. If you feel you need to use pointers (first consider if you really do), you would normally want to use a smart pointer as this can alleviate many of the problems with raw pointers, mainly forgetting to delete the object and leaking memory.

With raw pointers, the programmer has to explicitly destroy the object when it is no longer useful.

// Need to create the object to achieve some goal
MyObject* ptr = new MyObject(); 
ptr->DoSomething(); // Use the object in some way
delete ptr; // Destroy the object. Done with it.
// Wait, what if DoSomething() raises an exception...?

A smart pointer by comparison defines a policy as to when the object is destroyed. You still have to create the object, but you no longer have to worry about destroying it.

SomeSmartPtr<MyObject> ptr(new MyObject());
ptr->DoSomething(); // Use the object in some way.

// Destruction of the object happens, depending 
// on the policy the smart pointer class uses.

// Destruction would happen even if DoSomething() 
// raises an exception

The simplest policy in use involves the scope of the smart pointer wrapper object, such as implemented by boost::scoped_ptr or std::unique_ptr.

void f()
       boost::scoped_ptr<MyObject> ptr(new MyObject());
    } // boost::scopted_ptr goes out of scope -- 
      // the MyObject is automatically destroyed.

    // ptr->Oops(); // Compile error: "ptr" not defined
                    // since it is no longer in scope.

Note that scoped_ptr instances cannot be copied. This prevents the pointer from being deleted multiple times (incorrectly). You can, however, pass references to it around to other functions you call.

Scoped pointers are useful when you want to tie the lifetime of the object to a particular block of code, or if you embedded it as member data inside another object, the lifetime of that other object. The object exists until the containing block of code is exited, or until the containing object is itself destroyed.

A more complex smart pointer policy involves reference counting the pointer. This does allow the pointer to be copied. When the last “reference” to the object is destroyed, the object is deleted. This policy is implemented by boost::shared_ptr and std::shared_ptr.

void f()
    typedef std::shared_ptr<MyObject> MyObjectPtr; // nice short alias
    MyObjectPtr p1; // Empty

        MyObjectPtr p2(new MyObject());
        // There is now one "reference" to the created object
        p1 = p2; // Copy the pointer.
        // There are now two references to the object.
    } // p2 is destroyed, leaving one reference to the object.
} // p1 is destroyed, leaving a reference count of zero. 
  // The object is deleted.

Reference counted pointers are very useful when the lifetime of your object is much more complicated, and is not tied directly to a particular section of code or to another object.

There is one drawback to reference counted pointers — the possibility of creating a dangling reference:

// Create the smart pointer on the heap
MyObjectPtr* pp = new MyObjectPtr(new MyObject())
// Hmm, we forgot to destroy the smart pointer,
// because of that, the object is never destroyed!

Another possibility is creating circular references:

struct Owner {
   boost::shared_ptr<Owner> other;

boost::shared_ptr<Owner> p1 (new Owner());
boost::shared_ptr<Owner> p2 (new Owner());
p1->other = p2; // p1 references p2
p2->other = p1; // p2 references p1

// Oops, the reference count of of p1 and p2 never goes to zero!
// The objects are never destroyed!

To work around this problem, both Boost and C++11 have defined a weak_ptr to define a weak (uncounted) reference to a shared_ptr.

This answer is rather old, and so describes what was ‘good’ at the time, which was smart pointers provided by the Boost library. Since C++11, the standard library has provided sufficient smart pointers types, and so you should favour the use of std::unique_ptr, std::shared_ptr and std::weak_ptr.

There is also std::auto_ptr. It is very much like a scoped pointer, except that it also has the “special” dangerous ability to be copied — which also unexpectedly transfers ownership! It is deprecated in the newest standards, so you shouldn’t use it.

std::auto_ptr<MyObject> p1 (new MyObject());
std::auto_ptr<MyObject> p2 = p1; // Copy and transfer ownership. 
                                 // p1 gets set to empty!
p2->DoSomething(); // Works.
p1->DoSomething(); // Oh oh. Hopefully raises some NULL pointer exception.