Q:

Trying to get property of non-object CodeIgniter frame work

when i var dump $userData it will return 

array(1) { [0]=> object(stdClass)#19 (11) { ["id"]=> string(1) "1"
  ["title"]=> string(3) "Mrs" ["name"]=> string(6) "Devaka"
  ["username"]=> string(6) "Dabare" ["email"]=> string(23)
  "devakadabare1@gmail.com" ["contactnum"]=> string(10) "0750548469"
  ["user_address"]=> string(40) "260/B,Station Road, Angulana, Moratuwa"
  ["district"]=> string(7) "Colombo" ["password"]=> string(8) "12345679"
  ["buyer"]=> string(1) "1" ["seller"]=> string(1) "0" } }

but when i echo $userData->name
it will gives  error 

Trying to get property of non-object

user.php controller
defined('BASEPATH') OR exit('No direct script access allowed');

class User extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('User_model','',true);
    }

    public function index()
    {
        $data['userData'] = $this->User_model->getUser();
        //$data['userEditData'] = $result[0];
        $this->load->view('profile/index', $data);
    }

Model
class User_model extends CI_model{

     public function __construct() {
        parent::__construct();
    }

    public function getUser(){
        $query = $this->db->where(array('id'=>1))
            ->get('users');
        return $query->result();
    }

A:

If you want only single result(row) from database. Use $query->row(); instead of $query->result();
So change your model as below then try your code:
public function getUser(){
        $query = $this->db->where(array('id'=>1))
            ->get('users');
        return $query->row();
    }

